Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
8d0ba4a9
Commit
8d0ba4a9
authored
Feb 06, 2018
by
Simon Croome
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update storageos api dependency to 0.3.4
parent
68da4562
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
1330 additions
and
126 deletions
+1330
-126
Godeps.json
Godeps/Godeps.json
+14
-2
LICENSES
Godeps/LICENSES
+106
-0
BUILD
vendor/github.com/storageos/go-api/BUILD
+11
-42
README.md
vendor/github.com/storageos/go-api/README.md
+3
-0
client.go
vendor/github.com/storageos/go-api/client.go
+0
-0
client_unix.go
vendor/github.com/storageos/go-api/client_unix.go
+0
-25
client_windows.go
vendor/github.com/storageos/go-api/client_windows.go
+0
-40
controller.go
vendor/github.com/storageos/go-api/controller.go
+0
-1
health.go
vendor/github.com/storageos/go-api/health.go
+71
-0
logger.go
vendor/github.com/storageos/go-api/logger.go
+62
-0
login.go
vendor/github.com/storageos/go-api/login.go
+46
-0
BUILD
vendor/github.com/storageos/go-api/netutil/BUILD
+27
-0
errors.go
vendor/github.com/storageos/go-api/netutil/errors.go
+26
-0
multidialer.go
vendor/github.com/storageos/go-api/netutil/multidialer.go
+109
-0
parsers.go
vendor/github.com/storageos/go-api/netutil/parsers.go
+142
-0
policy.go
vendor/github.com/storageos/go-api/policy.go
+103
-0
rule.go
vendor/github.com/storageos/go-api/rule.go
+9
-4
BUILD
vendor/github.com/storageos/go-api/serror/BUILD
+28
-0
error_kind.go
vendor/github.com/storageos/go-api/serror/error_kind.go
+11
-0
kind_lookup_map.go
vendor/github.com/storageos/go-api/serror/kind_lookup_map.go
+37
-0
storageos_error.go
vendor/github.com/storageos/go-api/serror/storageos_error.go
+34
-0
storageoserrorkind_string.go
....com/storageos/go-api/serror/storageoserrorkind_string.go
+16
-0
typed_error.go
vendor/github.com/storageos/go-api/serror/typed_error.go
+64
-0
swagger-gen.yaml
vendor/github.com/storageos/go-api/swagger-gen.yaml
+0
-12
swagger.yaml
vendor/github.com/storageos/go-api/swagger.yaml
+0
-0
BUILD
vendor/github.com/storageos/go-api/types/BUILD
+4
-0
controller.go
vendor/github.com/storageos/go-api/types/controller.go
+4
-0
controller_update_options.go
...b.com/storageos/go-api/types/controller_update_options.go
+3
-0
deployment.go
vendor/github.com/storageos/go-api/types/deployment.go
+4
-0
logger.go
vendor/github.com/storageos/go-api/types/logger.go
+40
-0
node.go
vendor/github.com/storageos/go-api/types/node.go
+97
-0
policy.go
vendor/github.com/storageos/go-api/types/policy.go
+45
-0
user.go
vendor/github.com/storageos/go-api/types/user.go
+79
-0
volume.go
vendor/github.com/storageos/go-api/types/volume.go
+10
-0
volume_create_options.go
...ithub.com/storageos/go-api/types/volume_create_options.go
+3
-0
volume_update_options.go
...ithub.com/storageos/go-api/types/volume_update_options.go
+3
-0
user.go
vendor/github.com/storageos/go-api/user.go
+119
-0
No files found.
Godeps/Godeps.json
View file @
8d0ba4a9
...
...
@@ -2592,11 +2592,23 @@
},
{
"ImportPath"
:
"github.com/storageos/go-api"
,
"Rev"
:
"74f9beb613cacf0cc282facc2e1550a3231e126f"
"Comment"
:
"0.3.4"
,
"Rev"
:
"3a4032328d99c1b43fbda3d85bd3c80fa06e1707"
},
{
"ImportPath"
:
"github.com/storageos/go-api/netutil"
,
"Comment"
:
"0.3.4"
,
"Rev"
:
"3a4032328d99c1b43fbda3d85bd3c80fa06e1707"
},
{
"ImportPath"
:
"github.com/storageos/go-api/serror"
,
"Comment"
:
"0.3.4"
,
"Rev"
:
"3a4032328d99c1b43fbda3d85bd3c80fa06e1707"
},
{
"ImportPath"
:
"github.com/storageos/go-api/types"
,
"Rev"
:
"74f9beb613cacf0cc282facc2e1550a3231e126f"
"Comment"
:
"0.3.4"
,
"Rev"
:
"3a4032328d99c1b43fbda3d85bd3c80fa06e1707"
},
{
"ImportPath"
:
"github.com/stretchr/objx"
,
...
...
Godeps/LICENSES
View file @
8d0ba4a9
...
...
@@ -82053,6 +82053,112 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================
= vendor/github.com/storageos/go-api/netutil licensed under: =
MIT License
Copyright (c) 2015-2017 StorageOS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright (c) 2013-2017, go-dockerclient authors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
= vendor/github.com/storageos/go-api/LICENCE d8f852a0f38554263e64363f57b07fc4
================================================================================
================================================================================
= vendor/github.com/storageos/go-api/serror licensed under: =
MIT License
Copyright (c) 2015-2017 StorageOS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright (c) 2013-2017, go-dockerclient authors
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
= vendor/github.com/storageos/go-api/LICENCE d8f852a0f38554263e64363f57b07fc4
================================================================================
================================================================================
= vendor/github.com/storageos/go-api/types licensed under: =
MIT License
vendor/github.com/storageos/go-api/BUILD
View file @
8d0ba4a9
...
...
@@ -6,61 +6,28 @@ go_library(
"client.go",
"controller.go",
"event.go",
"health.go",
"logger.go",
"login.go",
"namespace.go",
"policy.go",
"pool.go",
"rule.go",
"server_version.go",
"template.go",
"user.go",
"util.go",
"validation.go",
"volume.go",
] + select({
"@io_bazel_rules_go//go/platform:android": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:darwin": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:dragonfly": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:freebsd": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:linux": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:nacl": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:netbsd": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:openbsd": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:plan9": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:solaris": [
"client_unix.go",
],
"@io_bazel_rules_go//go/platform:windows": [
"client_windows.go",
],
"//conditions:default": [],
}),
],
importpath = "github.com/storageos/go-api",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/gorilla/websocket:go_default_library",
"//vendor/github.com/storageos/go-api/netutil:go_default_library",
"//vendor/github.com/storageos/go-api/serror:go_default_library",
"//vendor/github.com/storageos/go-api/types:go_default_library",
] + select({
"@io_bazel_rules_go//go/platform:windows": [
"//vendor/github.com/Microsoft/go-winio:go_default_library",
],
"//conditions:default": [],
}),
],
)
filegroup(
...
...
@@ -74,6 +41,8 @@ filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//vendor/github.com/storageos/go-api/netutil:all-srcs",
"//vendor/github.com/storageos/go-api/serror:all-srcs",
"//vendor/github.com/storageos/go-api/types:all-srcs",
],
tags = ["automanaged"],
...
...
vendor/github.com/storageos/go-api/README.md
View file @
8d0ba4a9
# StorageOS API client library
## Swagger Spec
Swagger specification for this repo is available in the
[
StorageOS public documentation
](
https://github.com/storageos/storageos.github.io/blob/master/swagger.yaml
)
.
vendor/github.com/storageos/go-api/client.go
View file @
8d0ba4a9
This diff is collapsed.
Click to expand it.
vendor/github.com/storageos/go-api/client_unix.go
deleted
100644 → 0
View file @
68da4562
// +build !windows
// Copyright 2016 go-dockerclient authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
storageos
import
(
"net"
"net/http"
)
// initializeNativeClient initializes the native Unix domain socket client on
// Unix-style operating systems
func
(
c
*
Client
)
initializeNativeClient
()
{
if
c
.
endpointURL
.
Scheme
!=
unixProtocol
{
return
}
socketPath
:=
c
.
endpointURL
.
Path
tr
:=
defaultTransport
()
tr
.
Dial
=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
c
.
Dialer
.
Dial
(
unixProtocol
,
socketPath
)
}
c
.
nativeHTTPClient
=
&
http
.
Client
{
Transport
:
tr
}
}
vendor/github.com/storageos/go-api/client_windows.go
deleted
100644 → 0
View file @
68da4562
// +build windows
// Copyright 2016 go-dockerclient authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
storageos
import
(
"net"
"net/http"
"time"
"github.com/Microsoft/go-winio"
)
const
namedPipeConnectTimeout
=
2
*
time
.
Second
type
pipeDialer
struct
{
dialFunc
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
}
func
(
p
pipeDialer
)
Dial
(
network
,
address
string
)
(
net
.
Conn
,
error
)
{
return
p
.
dialFunc
(
network
,
address
)
}
// initializeNativeClient initializes the native Named Pipe client for Windows
func
(
c
*
Client
)
initializeNativeClient
()
{
if
c
.
endpointURL
.
Scheme
!=
namedPipeProtocol
{
return
}
namedPipePath
:=
c
.
endpointURL
.
Path
dialFunc
:=
func
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
timeout
:=
namedPipeConnectTimeout
return
winio
.
DialPipe
(
namedPipePath
,
&
timeout
)
}
tr
:=
defaultTransport
()
tr
.
Dial
=
dialFunc
c
.
Dialer
=
&
pipeDialer
{
dialFunc
}
c
.
nativeHTTPClient
=
&
http
.
Client
{
Transport
:
tr
}
}
vendor/github.com/storageos/go-api/controller.go
View file @
8d0ba4a9
...
...
@@ -26,7 +26,6 @@ func (c *Client) ControllerList(opts types.ListOptions) ([]*types.Controller, er
listOpts
:=
doOptions
{
fieldSelector
:
opts
.
FieldSelector
,
labelSelector
:
opts
.
LabelSelector
,
namespace
:
opts
.
Namespace
,
context
:
opts
.
Context
,
}
...
...
vendor/github.com/storageos/go-api/health.go
0 → 100644
View file @
8d0ba4a9
package
storageos
import
(
"context"
"encoding/json"
"fmt"
"net/http"
"github.com/storageos/go-api/types"
)
var
(
// HealthAPIPrefix is a partial path to the HTTP endpoint.
HealthAPIPrefix
=
"health"
)
// CPHealth returns the health of the control plane server at a given url.
func
(
c
*
Client
)
CPHealth
(
ctx
context
.
Context
,
hostname
string
)
(
*
types
.
CPHealthStatus
,
error
)
{
url
:=
fmt
.
Sprintf
(
"http://%s:%s/v1/%s"
,
hostname
,
DefaultPort
,
HealthAPIPrefix
)
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
req
.
Header
.
Set
(
"User-Agent"
,
userAgent
)
if
c
.
username
!=
""
&&
c
.
secret
!=
""
{
req
.
SetBasicAuth
(
c
.
username
,
c
.
secret
)
}
resp
,
err
:=
c
.
HTTPClient
.
Do
(
req
.
WithContext
(
ctx
))
if
err
!=
nil
{
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
var
status
*
types
.
CPHealthStatus
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
status
);
err
!=
nil
{
return
nil
,
err
}
return
status
,
nil
}
// DPHealth returns the health of the data plane server at a given url.
func
(
c
*
Client
)
DPHealth
(
ctx
context
.
Context
,
hostname
string
)
(
*
types
.
DPHealthStatus
,
error
)
{
url
:=
fmt
.
Sprintf
(
"http://%s:%s/v1/%s"
,
hostname
,
DataplaneHealthPort
,
HealthAPIPrefix
)
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
req
.
Header
.
Set
(
"User-Agent"
,
userAgent
)
if
c
.
username
!=
""
&&
c
.
secret
!=
""
{
req
.
SetBasicAuth
(
c
.
username
,
c
.
secret
)
}
resp
,
err
:=
c
.
HTTPClient
.
Do
(
req
.
WithContext
(
ctx
))
if
err
!=
nil
{
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
var
status
*
types
.
DPHealthStatus
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
status
);
err
!=
nil
{
return
nil
,
err
}
return
status
,
nil
}
vendor/github.com/storageos/go-api/logger.go
0 → 100644
View file @
8d0ba4a9
package
storageos
import
(
"context"
"encoding/json"
"net/url"
"github.com/storageos/go-api/types"
)
var
(
// LoggerAPIPrefix is a partial path to the HTTP endpoint.
LoggerAPIPrefix
=
"logs"
)
// LoggerConfig returns every cluster node's logging configuration.
func
(
c
*
Client
)
LoggerConfig
(
opts
types
.
ListOptions
)
([]
*
types
.
Logger
,
error
)
{
listOpts
:=
doOptions
{
fieldSelector
:
opts
.
FieldSelector
,
labelSelector
:
opts
.
LabelSelector
,
context
:
opts
.
Context
,
}
if
opts
.
LabelSelector
!=
""
{
query
:=
url
.
Values
{}
query
.
Add
(
"labelSelector"
,
opts
.
LabelSelector
)
listOpts
.
values
=
query
}
resp
,
err
:=
c
.
do
(
"GET"
,
LoggerAPIPrefix
+
"/cluster/config"
,
listOpts
)
if
err
!=
nil
{
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
var
loggers
[]
*
types
.
Logger
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
loggers
);
err
!=
nil
{
return
nil
,
err
}
return
loggers
,
nil
}
// LoggerUpdate patches updates to logging configuration. Fields to update must
// be listed in the Fields value, and if a list of Nodes is given it will only
// apply to the nodes listed. Returns the updated configuration.
func
(
c
*
Client
)
LoggerUpdate
(
opts
types
.
LoggerUpdateOptions
)
([]
*
types
.
Logger
,
error
)
{
resp
,
err
:=
c
.
do
(
"PATCH"
,
LoggerAPIPrefix
+
"/cluster/config"
,
doOptions
{
data
:
opts
,
context
:
context
.
Background
(),
})
if
err
!=
nil
{
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
var
loggers
[]
*
types
.
Logger
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
loggers
);
err
!=
nil
{
return
nil
,
err
}
return
loggers
,
nil
}
vendor/github.com/storageos/go-api/login.go
0 → 100644
View file @
8d0ba4a9
package
storageos
import
(
"encoding/json"
"errors"
)
var
(
// LoginAPIPrefix is a partial path to the HTTP endpoint.
LoginAPIPrefix
=
"auth/login"
ErrLoginFailed
=
errors
.
New
(
"Failed to get token from API endpoint"
)
)
// Login attemps to get a token from the API
func
(
c
*
Client
)
Login
()
(
token
string
,
err
error
)
{
resp
,
err
:=
c
.
do
(
"POST"
,
LoginAPIPrefix
,
doOptions
{
data
:
struct
{
User
string
`json:"username"`
Pass
string
`json:"password"`
}{
c
.
username
,
c
.
secret
}})
if
err
!=
nil
{
if
_
,
ok
:=
err
.
(
*
Error
);
ok
{
return
""
,
ErrLoginFailed
}
return
""
,
err
}
if
resp
.
StatusCode
!=
200
{
return
""
,
ErrLoginFailed
}
unmarsh
:=
struct
{
Token
string
`json:"token"`
}{}
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
unmarsh
);
err
!=
nil
{
return
""
,
err
}
if
unmarsh
.
Token
==
""
{
return
""
,
ErrLoginFailed
}
return
unmarsh
.
Token
,
nil
}
vendor/github.com/storageos/go-api/netutil/BUILD
0 → 100644
View file @
8d0ba4a9
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"errors.go",
"multidialer.go",
"parsers.go",
],
importpath = "github.com/storageos/go-api/netutil",
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/storageos/go-api/serror:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
vendor/github.com/storageos/go-api/netutil/errors.go
0 → 100644
View file @
8d0ba4a9
package
netutil
import
(
"errors"
"fmt"
"github.com/storageos/go-api/serror"
"strings"
)
func
errAllFailed
(
addrs
[]
string
)
error
{
msg
:=
fmt
.
Sprintf
(
"failed to dial all known cluster members, (%s)"
,
strings
.
Join
(
addrs
,
","
))
help
:=
"ensure that the value of $STORAGEOS_HOST (or the -H flag) is correct, and that there are healthy StorageOS nodes in this cluster"
return
serror
.
NewTypedStorageOSError
(
serror
.
APIUncontactable
,
nil
,
msg
,
help
)
}
func
newInvalidNodeError
(
err
error
)
error
{
msg
:=
fmt
.
Sprintf
(
"invalid node format: %s"
,
err
)
help
:=
"please check the format of $STORAGEOS_HOST (or the -H flag) complies with the StorageOS JOIN format"
return
serror
.
NewTypedStorageOSError
(
serror
.
InvalidHostConfig
,
err
,
msg
,
help
)
}
var
errNoAddresses
=
errors
.
New
(
"the MultiDialer instance has not been initialised with client addresses"
)
var
errUnsupportedScheme
=
errors
.
New
(
"unsupported URL scheme"
)
var
errInvalidPortNumber
=
errors
.
New
(
"invalid port number"
)
vendor/github.com/storageos/go-api/netutil/multidialer.go
0 → 100644
View file @
8d0ba4a9
package
netutil
import
(
"context"
"math/rand"
"net"
"time"
)
var
DefaultDialPort
=
"5705"
func
init
()
{
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
}
// Dialer is an interface that matches *net.Dialer. The intention is to allow either the stdlib
// dialer or a custom implementation to be passed to the MultiDialer constructor. This also makes
// the component easier to test.
type
Dialer
interface
{
DialContext
(
context
.
Context
,
string
,
string
)
(
net
.
Conn
,
error
)
}
// MultiDialer is a custom net Dialer (to be used in a net.Transport field) that attemps to dial
// out to any (potentialy many) of a set of pre-defined addresses. The intended use of this
// function is to extend the functionality of the stdlib http.Client to transparently support
// requests to any member of a given storageos cluster.
type
MultiDialer
struct
{
Addresses
[]
string
Dialer
*
net
.
Dialer
}
// NewMultiDialer returns a new MultiDialer instance, configured to dial out to the given set of
// nodes. Nodes can be provided using a URL format (e.g. http://google.com:80), or a host-port pair
// (e.g. localhost:4567).
//
// If a port number is omitted, the value of DefaultDialPort is used.
// Given hostnames are resolved to IP addresses, and IP addresses are used verbatim.
//
// If called with a non-nil dialer, the MultiDialer instance will use this for internall dial
// requests. If this value is nil, the function will initialise one with sane defaults.
func
NewMultiDialer
(
nodes
[]
string
,
dialer
*
net
.
Dialer
)
(
*
MultiDialer
,
error
)
{
// If a dialer is not provided, initialise one with sane defaults
if
dialer
==
nil
{
dialer
=
&
net
.
Dialer
{
Timeout
:
5
*
time
.
Second
,
KeepAlive
:
5
*
time
.
Second
,
}
}
addrs
,
err
:=
addrsFromNodes
(
nodes
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
MultiDialer
{
Addresses
:
addrs
,
Dialer
:
dialer
,
},
nil
}
// DialContext will dial each of the MultiDialer's internal addresses in a random order until one
// successfully returns a connection, it has run out of addresses (returning ErrAllFailed), or the
// given context has been closed.
//
// Due to the intrinsic behaviour of this function, any address passed to this function will be
// ignored.
func
(
m
*
MultiDialer
)
DialContext
(
ctx
context
.
Context
,
network
,
ignoredAddress
string
)
(
net
.
Conn
,
error
)
{
if
len
(
m
.
Addresses
)
==
0
{
return
nil
,
newInvalidNodeError
(
errNoAddresses
)
}
// Shuffle a copy of the addresses (for even load balancing)
addrs
:=
make
([]
string
,
len
(
m
.
Addresses
))
copy
(
addrs
,
m
.
Addresses
)
// Fisher–Yates shuffle algorithm
for
i
:=
len
(
addrs
)
-
1
;
i
>
0
;
i
--
{
j
:=
rand
.
Intn
(
i
+
1
)
addrs
[
i
],
addrs
[
j
]
=
addrs
[
j
],
addrs
[
i
]
}
// Try to dial each of these addresses in turn, or return on closed context
for
_
,
addr
:=
range
addrs
{
select
{
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
default
:
// Create new child context for a single dial
dctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
time
.
Second
)
defer
cancel
()
conn
,
err
:=
m
.
Dialer
.
DialContext
(
dctx
,
network
,
addr
)
if
err
!=
nil
{
continue
}
return
conn
,
nil
}
}
// We failed to dail all of the addresses we have
return
nil
,
errAllFailed
(
m
.
Addresses
)
}
// Dial returns the result of a call to m.DialContext passing in the background context
func
(
m
*
MultiDialer
)
Dial
(
network
,
addr
string
)
(
net
.
Conn
,
error
)
{
return
m
.
DialContext
(
context
.
Background
(),
network
,
addr
)
}
vendor/github.com/storageos/go-api/netutil/parsers.go
0 → 100644
View file @
8d0ba4a9
package
netutil
import
(
"net"
"net/url"
"strconv"
"strings"
)
// addrsFromNodes takes a list of node hosts and attempts to return a list of hosts in ip:port
// format along with any error encountered.
//
// The function accepts node hosts in URL, ip, ip:port, resolvable-name and resolvable-name:port
// formats and will append the default port value if needed.
func
addrsFromNodes
(
nodes
[]
string
)
([]
string
,
error
)
{
var
addrs
[]
string
for
_
,
n
:=
range
nodes
{
switch
{
// Assume that the node is provided as a URL
case
strings
.
Contains
(
n
,
"://"
)
:
newAddrs
,
err
:=
parseURL
(
n
)
if
err
!=
nil
{
return
nil
,
newInvalidNodeError
(
err
)
}
addrs
=
append
(
addrs
,
newAddrs
...
)
// Assume the node is in hostname:port or ip:port format
case
strings
.
Contains
(
n
,
":"
)
:
newAddrs
,
err
:=
parseHostPort
(
n
)
if
err
!=
nil
{
return
nil
,
newInvalidNodeError
(
err
)
}
addrs
=
append
(
addrs
,
newAddrs
...
)
// Assume hostname or ip
default
:
newAddrs
,
err
:=
parseHost
(
n
)
if
err
!=
nil
{
return
nil
,
newInvalidNodeError
(
err
)
}
addrs
=
append
(
addrs
,
newAddrs
...
)
}
}
return
addrs
,
nil
}
func
validPort
(
port
string
)
bool
{
intPort
,
err
:=
strconv
.
Atoi
(
port
)
return
(
err
==
nil
)
&&
(
intPort
>
0
)
&&
(
intPort
<=
65535
)
}
// parseURL takes a valid URL and verifies that it is using a correct scheme, has a resolvable
// address (or is an IP) and has a valid port (or adds the default if the port is omitted). The
// function then returns a list of addresses in ip:port format along with any error encountered.
//
// The function may return multiple addresses depending on the dns answer received when resolving
// the host.
func
parseURL
(
node
string
)
([]
string
,
error
)
{
url
,
err
:=
url
.
Parse
(
node
)
if
err
!=
nil
{
return
nil
,
err
}
// Verify a valid scheme
switch
url
.
Scheme
{
case
"tcp"
,
"http"
,
"https"
:
host
,
port
,
err
:=
net
.
SplitHostPort
(
url
.
Host
)
if
err
!=
nil
{
// We could be here as there is no port, lets try one last time with default port added
host
,
port
,
err
=
net
.
SplitHostPort
(
url
.
Host
+
":"
+
DefaultDialPort
)
if
err
!=
nil
{
return
nil
,
err
}
}
if
!
validPort
(
port
)
{
return
nil
,
errInvalidPortNumber
}
// LookupHost works for IP addr too
addrs
,
err
:=
net
.
LookupHost
(
host
)
if
err
!=
nil
{
return
nil
,
err
}
for
i
,
a
:=
range
addrs
{
addrs
[
i
]
=
a
+
":"
+
port
}
return
addrs
,
nil
default
:
return
nil
,
errUnsupportedScheme
}
}
// parseHostPort takes a string in host:port format and checks it has a resolvable address (or is
// an IP) and a valid port (or adds the default if the port is omitted). The function then returns
// a list of addresses in ip:port format along with any error encountered.
//
// The function may return multiple addresses depending on the dns answer received when resolving
// the host.
func
parseHostPort
(
node
string
)
([]
string
,
error
)
{
host
,
port
,
err
:=
net
.
SplitHostPort
(
node
)
if
err
!=
nil
{
return
nil
,
err
}
if
!
validPort
(
port
)
{
return
nil
,
errInvalidPortNumber
}
// LookupHost works for IP addr too
addrs
,
err
:=
net
.
LookupHost
(
host
)
if
err
!=
nil
{
return
nil
,
err
}
for
i
,
a
:=
range
addrs
{
addrs
[
i
]
=
a
+
":"
+
port
}
return
addrs
,
nil
}
// parseHostPort takes a hostname string and checks it is resolvable to an address (or is already
// an IP) The function then returns a list of addresses in ip:port format (where port is the
// default port) along with any error encountered.
//
// The function may return multiple addresses depending on the dns answer received when resolving
// the host.
func
parseHost
(
node
string
)
([]
string
,
error
)
{
return
parseHostPort
(
node
+
":"
+
DefaultDialPort
)
}
vendor/github.com/storageos/go-api/policy.go
0 → 100644
View file @
8d0ba4a9
package
storageos
import
(
"context"
"encoding/json"
"errors"
"fmt"
"github.com/storageos/go-api/types"
"net/http"
"net/url"
)
var
(
// PolicyAPIPrefix is a partial path to the HTTP endpoint.
PolicyAPIPrefix
=
"policies"
// ErrNoSuchPolicy is the error returned when the policy does not exist.
ErrNoSuchPolicy
=
errors
.
New
(
"no such policy"
)
)
// nopMarshaler is an alias to a []byte that implements json.Marshaler
// it bypasses the base64 encoded string representation that json will give byte slices.
// It should only be used to wrap []byte types containing pre-rendered valid json that will later
// (out of the caller's control) be run through json.Marshal
type
nopMarshaler
[]
byte
func
(
n
*
nopMarshaler
)
MarshalJSON
()
([]
byte
,
error
)
{
return
*
n
,
nil
}
// PolicyCreate creates a policy on the server.
func
(
c
*
Client
)
PolicyCreate
(
jsonl
[]
byte
,
ctx
context
.
Context
)
error
{
nopm
:=
nopMarshaler
(
jsonl
)
_
,
err
:=
c
.
do
(
"POST"
,
PolicyAPIPrefix
,
doOptions
{
data
:
&
nopm
,
context
:
ctx
,
headers
:
map
[
string
]
string
{
"Content-Type"
:
"application/x-jsonlines"
},
})
return
err
}
// Policy returns a policy on the server by ID.
func
(
c
*
Client
)
Policy
(
id
string
)
(
*
types
.
Policy
,
error
)
{
path
:=
fmt
.
Sprintf
(
"%s/%s"
,
PolicyAPIPrefix
,
id
)
resp
,
err
:=
c
.
do
(
"GET"
,
path
,
doOptions
{})
if
err
!=
nil
{
if
e
,
ok
:=
err
.
(
*
Error
);
ok
&&
e
.
Status
==
http
.
StatusNotFound
{
return
nil
,
ErrNoSuchPolicy
}
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
var
policy
*
types
.
Policy
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
policy
);
err
!=
nil
{
return
nil
,
err
}
return
policy
,
nil
}
// PolicyList returns the list of policies on the server.
func
(
c
*
Client
)
PolicyList
(
opts
types
.
ListOptions
)
(
types
.
PolicySet
,
error
)
{
listOpts
:=
doOptions
{
fieldSelector
:
opts
.
FieldSelector
,
labelSelector
:
opts
.
LabelSelector
,
namespace
:
opts
.
Namespace
,
context
:
opts
.
Context
,
}
if
opts
.
LabelSelector
!=
""
{
query
:=
url
.
Values
{}
query
.
Add
(
"labelSelector"
,
opts
.
LabelSelector
)
listOpts
.
values
=
query
}
resp
,
err
:=
c
.
do
(
"GET"
,
PolicyAPIPrefix
,
listOpts
)
if
err
!=
nil
{
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
var
policies
types
.
PolicySet
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
policies
);
err
!=
nil
{
return
nil
,
err
}
return
policies
,
nil
}
// PolicyDelete deletes a policy on the server by ID.
func
(
c
*
Client
)
PolicyDelete
(
opts
types
.
DeleteOptions
)
error
{
resp
,
err
:=
c
.
do
(
"DELETE"
,
PolicyAPIPrefix
+
"/"
+
opts
.
Name
,
doOptions
{})
if
err
!=
nil
{
if
e
,
ok
:=
err
.
(
*
Error
);
ok
{
if
e
.
Status
==
http
.
StatusNotFound
{
return
ErrNoSuchPolicy
}
}
return
err
}
defer
resp
.
Body
.
Close
()
return
nil
}
vendor/github.com/storageos/go-api/rule.go
View file @
8d0ba4a9
...
...
@@ -72,10 +72,15 @@ func (c *Client) Rule(namespace string, ref string) (*types.Rule, error) {
// RuleCreate creates a rule on the server and returns the new object.
func
(
c
*
Client
)
RuleCreate
(
opts
types
.
RuleCreateOptions
)
(
*
types
.
Rule
,
error
)
{
resp
,
err
:=
c
.
do
(
"POST"
,
RuleAPIPrefix
,
doOptions
{
data
:
opts
,
namespace
:
opts
.
Namespace
,
context
:
opts
.
Context
,
path
,
err
:=
namespacedPath
(
opts
.
Namespace
,
RuleAPIPrefix
)
if
err
!=
nil
{
return
nil
,
err
}
resp
,
err
:=
c
.
do
(
"POST"
,
path
,
doOptions
{
data
:
opts
,
// namespace: opts.Namespace,
context
:
opts
.
Context
,
})
if
err
!=
nil
{
return
nil
,
err
...
...
vendor/github.com/storageos/go-api/serror/BUILD
0 → 100644
View file @
8d0ba4a9
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"],
)
vendor/github.com/storageos/go-api/serror/error_kind.go
0 → 100644
View file @
8d0ba4a9
package
serror
//go:generate stringer -type=StorageOSErrorKind error_kind.go
type
StorageOSErrorKind
int
// Known error kinds
const
(
UnknownError
StorageOSErrorKind
=
iota
APIUncontactable
InvalidHostConfig
)
vendor/github.com/storageos/go-api/serror/kind_lookup_map.go
0 → 100644
View file @
8d0ba4a9
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
())
}
vendor/github.com/storageos/go-api/serror/storageos_error.go
0 → 100644
View file @
8d0ba4a9
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
}
vendor/github.com/storageos/go-api/serror/storageoserrorkind_string.go
0 → 100644
View file @
8d0ba4a9
// 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
]]
}
vendor/github.com/storageos/go-api/serror/typed_error.go
0 → 100644
View file @
8d0ba4a9
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
}
vendor/github.com/storageos/go-api/swagger-gen.yaml
deleted
100644 → 0
View file @
68da4562
layout
:
models
:
-
name
:
definition
source
:
asset:model
target
:
"
{{
joinFilePath
.Target
.ModelPackage
}}"
file_name
:
"
{{
(snakize
(pascalize
.Name))
}}.go"
operations
:
-
name
:
handler
source
:
asset:serverOperation
target
:
"
{{
joinFilePath
.Target
.APIPackage
.Package
}}"
file_name
:
"
{{
(snakize
(pascalize
.Name))
}}.go"
vendor/github.com/storageos/go-api/swagger.yaml
deleted
100644 → 0
View file @
68da4562
This diff is collapsed.
Click to expand it.
vendor/github.com/storageos/go-api/types/BUILD
View file @
8d0ba4a9
...
...
@@ -13,13 +13,17 @@ go_library(
"error_response.go",
"events.go",
"list_options.go",
"logger.go",
"namespace.go",
"node.go",
"operator.go",
"policy.go",
"pool.go",
"pool_create_options.go",
"rule.go",
"template.go",
"template_create_options.go",
"user.go",
"version.go",
"volume.go",
"volume_create_options.go",
...
...
vendor/github.com/storageos/go-api/types/controller.go
View file @
8d0ba4a9
...
...
@@ -41,6 +41,7 @@ type Controller struct {
Scheduler
bool
`json:"scheduler"`
Name
string
`json:"name"`
Address
string
`json:"address"`
DeviceDir
string
`json:"deviceDir"`
APIPort
int
`json:"apiPort"`
NatsPort
int
`json:"natsPort"`
NatsClusterPort
int
`json:"natsClusterPort"`
...
...
@@ -59,6 +60,9 @@ type Controller struct {
VersionInfo
map
[
string
]
VersionInfo
`json:"versionInfo"`
Version
string
`json:"version"`
// Cordon true if in an unschedulable state
Cordon
bool
`json:"unschedulable"`
// high level stats that combine info from all driver instances
CapacityStats
CapacityStats
`json:"capacityStats"`
}
...
...
vendor/github.com/storageos/go-api/types/controller_update_options.go
View file @
8d0ba4a9
...
...
@@ -19,6 +19,9 @@ type ControllerUpdateOptions struct {
// Labels are user-defined key/value metadata.
Labels
map
[
string
]
string
`json:"labels"`
// Cordon sets the controler into an unschedulable state if true
Cordon
bool
`json:"unschedulable"`
// Context can be set with a timeout or can be used to cancel a request.
Context
context
.
Context
`json:"-"`
}
vendor/github.com/storageos/go-api/types/deployment.go
View file @
8d0ba4a9
...
...
@@ -18,6 +18,10 @@ type Deployment struct {
// Read Only: true
Controller
string
`json:"controller"`
// Controller name
// Read Only: true
ControllerName
string
`json:"controllerName"`
// Health
// Read Only: true
Health
string
`json:"health"`
...
...
vendor/github.com/storageos/go-api/types/logger.go
0 → 100644
View file @
8d0ba4a9
package
types
import
"context"
// Logger is the runtime configuration of the node's logging services.
// swagger:model Logger
type
Logger
struct
{
// Node name
Node
string
`json:"node"`
// Log level
Level
string
`json:"level"`
// Log filter
Filter
string
`json:"filter"`
// Log filters by category
// Read Only: true
Categories
map
[
string
]
string
`json:"categories"`
}
// LoggerUpdateOptions are the available parameters for updating loggers.
type
LoggerUpdateOptions
struct
{
// Log level
Level
string
`json:"level"`
// Log filter
Filter
string
`json:"filter"`
// List of nodes to update. All if not set.
Nodes
[]
string
`json:"nodes"`
// List of fields to update. Must be set.
Fields
[]
string
`json:"fields"`
// Context can be set with a timeout or can be used to cancel a request.
Context
context
.
Context
`json:"-"`
}
vendor/github.com/storageos/go-api/types/node.go
0 → 100644
View file @
8d0ba4a9
package
types
import
(
"encoding/json"
)
type
SubModuleStatus
struct
{
Status
string
`json:"status"`
UpdatedAt
string
`json:"updatedAt"`
ChangedAt
string
`json:"changedAt"`
Message
string
`json:"message"`
}
type
NamedSubModuleStatus
struct
{
Name
string
SubModuleStatus
}
type
CPHealthStatus
struct
{
KV
SubModuleStatus
KVWrite
SubModuleStatus
NATS
SubModuleStatus
Scheduler
SubModuleStatus
}
func
(
c
*
CPHealthStatus
)
ToNamedSubmodules
()
[]
NamedSubModuleStatus
{
return
[]
NamedSubModuleStatus
{
{
Name
:
"nats"
,
SubModuleStatus
:
c
.
NATS
},
{
Name
:
"kv"
,
SubModuleStatus
:
c
.
KV
},
{
Name
:
"kv_write"
,
SubModuleStatus
:
c
.
KVWrite
},
{
Name
:
"scheduler"
,
SubModuleStatus
:
c
.
Scheduler
},
}
}
func
(
c
*
CPHealthStatus
)
UnmarshalJSON
(
data
[]
byte
)
error
{
unmarsh
:=
struct
{
Submodules
struct
{
KV
SubModuleStatus
`json:"kv"`
KVWrite
SubModuleStatus
`json:"kv_write"`
NATS
SubModuleStatus
`json:"nats"`
Scheduler
SubModuleStatus
`json:"scheduler"`
}
`json:"submodules"`
}{}
if
err
:=
json
.
Unmarshal
(
data
,
&
unmarsh
);
err
!=
nil
{
return
err
}
c
.
KV
=
unmarsh
.
Submodules
.
KV
c
.
KVWrite
=
unmarsh
.
Submodules
.
KVWrite
c
.
NATS
=
unmarsh
.
Submodules
.
NATS
c
.
Scheduler
=
unmarsh
.
Submodules
.
Scheduler
return
nil
}
type
DPHealthStatus
struct
{
DirectFSClient
SubModuleStatus
DirectFSServer
SubModuleStatus
Director
SubModuleStatus
FSDriver
SubModuleStatus
FS
SubModuleStatus
}
func
(
d
*
DPHealthStatus
)
ToNamedSubmodules
()
[]
NamedSubModuleStatus
{
return
[]
NamedSubModuleStatus
{
{
Name
:
"dfs_client"
,
SubModuleStatus
:
d
.
DirectFSClient
},
{
Name
:
"dfs_server"
,
SubModuleStatus
:
d
.
DirectFSServer
},
{
Name
:
"director"
,
SubModuleStatus
:
d
.
Director
},
{
Name
:
"fs_driver"
,
SubModuleStatus
:
d
.
FSDriver
},
{
Name
:
"fs"
,
SubModuleStatus
:
d
.
FS
},
}
}
func
(
d
*
DPHealthStatus
)
UnmarshalJSON
(
data
[]
byte
)
error
{
unmarsh
:=
struct
{
Submodules
struct
{
DirectFSClient
SubModuleStatus
`json:"directfs-client"`
DirectFSServer
SubModuleStatus
`json:"directfs-server"`
Director
SubModuleStatus
`json:"director"`
FSDriver
SubModuleStatus
`json:"filesystem-driver"`
FS
SubModuleStatus
`json:"fs"`
}
`json:"submodules"`
}{}
if
err
:=
json
.
Unmarshal
(
data
,
&
unmarsh
);
err
!=
nil
{
return
err
}
d
.
DirectFSClient
=
unmarsh
.
Submodules
.
DirectFSClient
d
.
DirectFSServer
=
unmarsh
.
Submodules
.
DirectFSServer
d
.
Director
=
unmarsh
.
Submodules
.
Director
d
.
FSDriver
=
unmarsh
.
Submodules
.
FSDriver
d
.
FS
=
unmarsh
.
Submodules
.
FS
return
nil
}
vendor/github.com/storageos/go-api/types/policy.go
0 → 100644
View file @
8d0ba4a9
package
types
import
(
"encoding/json"
)
type
Policy
struct
{
Spec
struct
{
User
string
`json:"user,omitempty"`
Group
string
`json:"group,omitempty"`
Readonly
bool
`json:"readonly,omitempty"`
APIGroup
string
`json:"apiGroup,omitempty"`
Resource
string
`json:"resource,omitempty"`
Namespace
string
`json:"namespace,omitempty"`
NonResourcePath
string
`json:"nonResourcePath,omitempty"`
}
`json:"spec"`
}
// PolicyWithId is used as an internal type to render table formated versions of the json response
type
PolicyWithID
struct
{
Policy
ID
string
}
// MarshalJSON returns a marshaled copy of the internal policy object, so it is still valid to use
// with the REST API
func
(
p
*
PolicyWithID
)
MarshalJSON
()
([]
byte
,
error
)
{
return
json
.
Marshal
(
p
.
Policy
)
}
// PolicySet is a representation of the data structure returned from the REST API
type
PolicySet
map
[
string
]
Policy
func
(
p
PolicySet
)
GetPoliciesWithID
()
[]
*
PolicyWithID
{
rtn
:=
make
([]
*
PolicyWithID
,
0
,
len
(
p
))
for
k
,
v
:=
range
p
{
rtn
=
append
(
rtn
,
&
PolicyWithID
{
Policy
:
v
,
ID
:
k
,
})
}
return
rtn
}
vendor/github.com/storageos/go-api/types/user.go
0 → 100644
View file @
8d0ba4a9
package
types
import
(
"context"
"encoding/json"
"strings"
)
type
User
struct
{
UUID
string
`json:"id"`
Username
string
`json:"username"`
Groups
[]
string
`json:"groups"`
Password
string
`json:"password,omitempty"`
Role
string
`json:"role"`
}
func
(
u
*
User
)
MarshalJSON
()
([]
byte
,
error
)
{
return
json
.
Marshal
(
&
struct
{
UUID
string
`json:"id"`
Username
string
`json:"username"`
Groups
string
`json:"groups"`
Password
string
`json:"password,omitempty"`
Role
string
`json:"role"`
}{
UUID
:
u
.
UUID
,
Username
:
u
.
Username
,
Groups
:
strings
.
Join
(
u
.
Groups
,
","
),
Password
:
u
.
Password
,
Role
:
u
.
Role
,
})
}
func
(
u
*
User
)
UnmarshalJSON
(
data
[]
byte
)
error
{
temp
:=
&
struct
{
UUID
string
`json:"id"`
Username
string
`json:"username"`
Groups
string
`json:"groups"`
Password
string
`json:"password"`
Role
string
`json:"role"`
}{}
if
err
:=
json
.
Unmarshal
(
data
,
temp
);
err
!=
nil
{
return
err
}
u
.
UUID
=
temp
.
UUID
u
.
Username
=
temp
.
Username
u
.
Password
=
temp
.
Password
u
.
Role
=
temp
.
Role
u
.
Groups
=
strings
.
Split
(
temp
.
Groups
,
","
)
return
nil
}
type
UserCreateOptions
struct
{
Username
string
`json:"username"`
Groups
[]
string
`json:"groups"`
Password
string
`json:"password"`
Role
string
`json:"role"`
// Context can be set with a timeout or can be used to cancel a request.
Context
context
.
Context
`json:"-"`
}
func
(
u
UserCreateOptions
)
MarshalJSON
()
([]
byte
,
error
)
{
return
json
.
Marshal
(
&
struct
{
Username
string
`json:"username"`
Groups
string
`json:"groups"`
Password
string
`json:"password"`
Role
string
`json:"role"`
}{
Username
:
u
.
Username
,
Groups
:
strings
.
Join
(
u
.
Groups
,
","
),
Password
:
u
.
Password
,
Role
:
u
.
Role
,
})
}
vendor/github.com/storageos/go-api/types/volume.go
View file @
8d0ba4a9
...
...
@@ -43,6 +43,9 @@ type Volume struct {
// Namespace is the object name and authentication scope, such as for teams and projects.
Namespace
string
`json:"namespace"`
// node selector (where volumes should land)
NodeSelector
string
`json:"nodeSelector"`
// Volume deployment information for the master volume.
// Read Only: true
Master
*
Deployment
`json:"master,omitempty"`
...
...
@@ -51,6 +54,9 @@ type Volume struct {
// Read Only: true
Mounted
bool
`json:"mounted"`
// MountDevice, where the device is located
MountDevice
string
`json:"mountDevice"`
// Mountpoint, where the volume is mounted
Mountpoint
string
`json:"mountpoint"`
...
...
@@ -78,6 +84,10 @@ type Volume struct {
// Read Only: true
StatusMessage
string
`json:"statusMessage"`
// mkfs performed on new volumes
MkfsDone
bool
`json:"mkfsDone"`
MkfsDoneAt
time
.
Time
`json:"mkfsDoneAt"`
// When the volume was created.
// Read Only: true
CreatedAt
time
.
Time
`json:"createdAt"`
...
...
vendor/github.com/storageos/go-api/types/volume_create_options.go
View file @
8d0ba4a9
...
...
@@ -25,6 +25,9 @@ type VolumeCreateOptions struct {
// Namespace is the object scope, such as for teams and projects.
Namespace
string
`json:"namespace"`
// node selector (where volumes should land)
NodeSelector
string
`json:"nodeSelector"`
// Labels are user-defined key/value metadata.
Labels
map
[
string
]
string
`json:"labels"`
...
...
vendor/github.com/storageos/go-api/types/volume_update_options.go
View file @
8d0ba4a9
...
...
@@ -23,6 +23,9 @@ type VolumeUpdateOptions struct {
// Namespace is the object scope, such as for teams and projects.
Namespace
string
`json:"namespace"`
// node selector (where volumes should land)
NodeSelector
string
`json:"nodeSelector"`
// Labels are user-defined key/value metadata.
Labels
map
[
string
]
string
`json:"labels"`
...
...
vendor/github.com/storageos/go-api/user.go
0 → 100644
View file @
8d0ba4a9
package
storageos
import
(
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"github.com/storageos/go-api/types"
)
var
(
// UserAPIPrefix is a partial path to the HTTP endpoint.
UserAPIPrefix
=
"users"
// ErrNoSuchUser is the error returned when the user does not exist.
ErrNoSuchUser
=
errors
.
New
(
"no such user"
)
)
// UserList returns the list of available users.
func
(
c
*
Client
)
UserList
(
opts
types
.
ListOptions
)
([]
*
types
.
User
,
error
)
{
listOpts
:=
doOptions
{
fieldSelector
:
opts
.
FieldSelector
,
labelSelector
:
opts
.
LabelSelector
,
namespace
:
opts
.
Namespace
,
context
:
opts
.
Context
,
}
if
opts
.
LabelSelector
!=
""
{
query
:=
url
.
Values
{}
query
.
Add
(
"labelSelector"
,
opts
.
LabelSelector
)
listOpts
.
values
=
query
}
resp
,
err
:=
c
.
do
(
"GET"
,
UserAPIPrefix
,
listOpts
)
if
err
!=
nil
{
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
users
:=
make
([]
*
types
.
User
,
0
)
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
users
);
err
!=
nil
{
return
nil
,
err
}
return
users
,
nil
}
// User returns a user by its username/id.
func
(
c
*
Client
)
User
(
username
string
)
(
*
types
.
User
,
error
)
{
path
:=
fmt
.
Sprintf
(
"%s/%s"
,
UserAPIPrefix
,
username
)
resp
,
err
:=
c
.
do
(
"GET"
,
path
,
doOptions
{})
if
err
!=
nil
{
if
e
,
ok
:=
err
.
(
*
Error
);
ok
&&
e
.
Status
==
http
.
StatusNotFound
{
return
nil
,
ErrNoSuchUser
}
return
nil
,
err
}
defer
resp
.
Body
.
Close
()
var
user
*
types
.
User
if
err
:=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
user
);
err
!=
nil
{
return
nil
,
err
}
return
user
,
nil
}
// UserCreate creates a user on the server.
func
(
c
*
Client
)
UserCreate
(
opts
types
.
UserCreateOptions
)
error
{
_
,
err
:=
c
.
do
(
"POST"
,
UserAPIPrefix
,
doOptions
{
data
:
opts
,
context
:
opts
.
Context
,
})
return
err
}
// UserUpdate updates a user on the server.
func
(
c
*
Client
)
UserUpdate
(
user
*
types
.
User
,
ctx
context
.
Context
)
error
{
var
ref
string
switch
{
case
user
.
UUID
!=
""
:
ref
=
user
.
UUID
case
user
.
Username
!=
""
:
ref
=
user
.
Username
default
:
return
ErrNoSuchUser
}
path
:=
fmt
.
Sprintf
(
"%s/%s"
,
UserAPIPrefix
,
ref
)
resp
,
err
:=
c
.
do
(
"POST"
,
path
,
doOptions
{
data
:
user
,
context
:
ctx
,
})
if
err
!=
nil
{
if
e
,
ok
:=
err
.
(
*
Error
);
ok
&&
e
.
Status
==
http
.
StatusNotFound
{
return
ErrNoSuchUser
}
return
err
}
defer
resp
.
Body
.
Close
()
return
nil
}
// UserDelete removes a user by its reference.
func
(
c
*
Client
)
UserDelete
(
opts
types
.
DeleteOptions
)
error
{
resp
,
err
:=
c
.
do
(
"DELETE"
,
UserAPIPrefix
+
"/"
+
opts
.
Name
,
doOptions
{})
if
err
!=
nil
{
if
e
,
ok
:=
err
.
(
*
Error
);
ok
{
if
e
.
Status
==
http
.
StatusNotFound
{
return
ErrNoSuchUser
}
}
return
err
}
defer
resp
.
Body
.
Close
()
return
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment