mirror of
https://github.com/josmo/drone-rancher.git
synced 2026-06-04 18:24:22 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5879d6c388 | |||
| 5eaa1bfabd | |||
| 630372a926 | |||
| 812150a0cf | |||
| 881ee630a1 | |||
| 9ef2dfa0bf | |||
| a4ec7afc63 | |||
| 0b869882ab | |||
| bce78f9af3 | |||
| d2e78c33a8 | |||
| ee2fc1628c | |||
| b17ee8517e | |||
| 2e35c06d75 | |||
| c1ed692bf0 | |||
| 589e865c70 |
+96
-75
@@ -1,93 +1,114 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
workspace:
|
||||
base: /go
|
||||
path: src/github.com/josmo/drone-rancher
|
||||
pipeline:
|
||||
test:
|
||||
image: golang:1.9
|
||||
commands:
|
||||
- go vet
|
||||
- go test -cover -coverprofile=coverage.out
|
||||
steps:
|
||||
- name: deps
|
||||
image: golang:1.10
|
||||
pull: true
|
||||
commands:
|
||||
- go get -u github.com/golang/dep/cmd/dep
|
||||
- dep ensure
|
||||
|
||||
build_linux_amd64:
|
||||
image: golang:1.9
|
||||
group: build
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=amd64
|
||||
- CGO_ENABLED=0
|
||||
commands:
|
||||
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/drone-rancher
|
||||
- name: test
|
||||
image: golang:1.10
|
||||
depends_on:
|
||||
- deps
|
||||
commands:
|
||||
- go vet
|
||||
- go test -cover -coverprofile=coverage.out
|
||||
|
||||
build_linux_arm64:
|
||||
image: golang:1.9
|
||||
group: build
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=arm64
|
||||
- CGO_ENABLED=0
|
||||
commands:
|
||||
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/drone-rancher
|
||||
- name: build_linux_amd64
|
||||
image: golang:1.10
|
||||
depends_on: [ test]
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: amd64
|
||||
CGO_ENABLED: 0
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/${DRONE_REPO_NAME}
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/amd64/${DRONE_REPO_NAME}
|
||||
fi
|
||||
|
||||
build_linux_arm:
|
||||
image: golang:1.9
|
||||
group: build
|
||||
environment:
|
||||
- GOOS=linux
|
||||
- GOARCH=arm
|
||||
- CGO_ENABLED=0
|
||||
- GOARM=7
|
||||
commands:
|
||||
- go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/drone-rancher
|
||||
- name: build_linux_arm64
|
||||
image: golang:1.10
|
||||
depends_on: [ test ]
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: arm64
|
||||
CGO_ENABLED: 0
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/${DRONE_REPO_NAME}
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm64/${DRONE_REPO_NAME}
|
||||
fi
|
||||
|
||||
# build_windows_amd64:
|
||||
# image: golang:1.9-nanoserver
|
||||
# group: build
|
||||
# environment:
|
||||
# - GOOS=windows
|
||||
# - GOARCH=amd64
|
||||
# - CGO_ENABLED=0
|
||||
# commands:
|
||||
# - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/windows/amd64/drone-webhook
|
||||
- name: build_linux_arm
|
||||
image: golang:1.10
|
||||
depends_on: [ test ]
|
||||
environment:
|
||||
GOOS: linux
|
||||
GOARCH: arm
|
||||
CGO_ENABLED: 0
|
||||
GOARM: 7
|
||||
commands:
|
||||
- |
|
||||
if test "${DRONE_TAG}" = ""; then
|
||||
go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/${DRONE_REPO_NAME}
|
||||
else
|
||||
go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/linux/arm/${DRONE_REPO_NAME}
|
||||
fi
|
||||
|
||||
publish_linux_amd64:
|
||||
image: plugins/docker
|
||||
username: josmo
|
||||
repo: peloton/drone-rancher
|
||||
- name: publish_linux_amd64
|
||||
image: plugins/docker
|
||||
depends_on: [ build_linux_amd64 ]
|
||||
settings:
|
||||
auto_tag: true
|
||||
secrets: [ docker_password ]
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo:
|
||||
from_secret: plugin_repo
|
||||
dockerfile: Dockerfile
|
||||
when:
|
||||
event: tag
|
||||
when:
|
||||
event: [ tag, push ]
|
||||
|
||||
publish_linux_arm64:
|
||||
image: plugins/docker
|
||||
username: josmo
|
||||
repo: peloton/drone-rancher
|
||||
- name: publish_linux_arm64
|
||||
image: plugins/docker
|
||||
depends_on: [ build_linux_arm64 ]
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
secrets: [ docker_password ]
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo:
|
||||
from_secret: plugin_repo
|
||||
dockerfile: Dockerfile.arm64
|
||||
when:
|
||||
event: tag
|
||||
when:
|
||||
event: [ tag, push ]
|
||||
|
||||
publish_linux_arm:
|
||||
image: plugins/docker
|
||||
username: josmo
|
||||
repo: peloton/drone-rancher
|
||||
- name: publish_linux_arm
|
||||
image: plugins/docker
|
||||
depends_on: [ build_linux_arm ]
|
||||
settings:
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
secrets: [ docker_password ]
|
||||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
repo:
|
||||
from_secret: plugin_repo
|
||||
dockerfile: Dockerfile.arm
|
||||
when:
|
||||
event: tag
|
||||
|
||||
# publish_windows_amd64:
|
||||
# image: plugins/docker
|
||||
# username: josmo
|
||||
# repo: peloton/drone-rancher
|
||||
# tags: [ windows-amd64 ]
|
||||
# secrets: [ docker_password ]
|
||||
# dockerfile: Dockerfile.windows
|
||||
# when:
|
||||
# branch: master
|
||||
# event: push
|
||||
when:
|
||||
event: [ tag, push ]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<!-- PLEASE READ BEFORE DELETING
|
||||
|
||||
Bugs or Issues?
|
||||
|
||||
-->
|
||||
@@ -0,0 +1,6 @@
|
||||
<!-- PLEASE READ BEFORE DELETING
|
||||
|
||||
Please discuss changes before creating pull requests.
|
||||
|
||||
|
||||
-->
|
||||
@@ -27,3 +27,5 @@ coverage.out
|
||||
drone-rancher
|
||||
|
||||
*.idea
|
||||
vendor
|
||||
release
|
||||
|
||||
@@ -3,10 +3,11 @@ Use the rancher plugin to upgrade a service in [rancher](http://rancher.com).
|
||||
The following parameters are used to configure this plugin:
|
||||
|
||||
- `url` - url to your rancher server, including protocol and port
|
||||
- `rancher_access_key` - rancher api access key
|
||||
- `rancher_secret_key` - rancher api secret key
|
||||
- `access_key` - rancher api access key
|
||||
- `secret_key` - rancher api secret key
|
||||
- `service` - name of rancher service to act on
|
||||
- `docker_image` - new image to assign to service, including tag (`drone/drone:latest`)
|
||||
- `sidekick` - sidekick name and docker image separated by space, multiple declaration supported
|
||||
- `start_first` - start the new container before stopping the old one, defaults to `true`
|
||||
- `confirm` - auto confirm the service upgrade if successful, defaults to `false`
|
||||
- `timeout` - the maximum wait time in seconds for the service to upgrade, default to `30`
|
||||
@@ -18,15 +19,17 @@ The following is a sample Rancher configuration in your `.drone.yml` file:
|
||||
```yaml
|
||||
deploy:
|
||||
rancher:
|
||||
image: peloton/drone-rancher
|
||||
image: pelotech/drone-rancher
|
||||
url: https://example.rancher.com
|
||||
access_key: 1234567abcdefg
|
||||
secret_key: abcdefg1234567
|
||||
service: drone/drone
|
||||
sidekick: nginx nginx:latest
|
||||
sidekick: node node:latest
|
||||
docker_image: drone/drone:latest
|
||||
```
|
||||
|
||||
if you want to add secrets for the access_key and secret it's RANCHER_ACCESS_KEY and RANCHER_SECRET_KEY
|
||||
if you want to add secrets for the access_key and secret_key it's RANCHER_ACCESS_KEY and RANCHER_SECRET_KEY
|
||||
|
||||
|
||||
Note that if your `service` is part of a stack, you should use the notation `stackname/servicename` as this will make sure that the found service is part of the correct stack. If no stack is specified, this plugin will update the first service with a matching name which may not be what you want.
|
||||
|
||||
Generated
+72
@@ -0,0 +1,72 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d867dfa6751c8d7a435821ad3b736310c2ed68945d05b50fb9d23aee0540c8cc"
|
||||
name = "github.com/Sirupsen/logrus"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "3e01752db0189b9157070a0e1668a620f9a85da2"
|
||||
version = "v1.0.6"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:43dd08a10854b2056e615d1b1d22ac94559d822e1f8b6fcc92c1a1057e85188e"
|
||||
name = "github.com/gorilla/websocket"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747"
|
||||
name = "github.com/pkg/errors"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
|
||||
version = "v0.8.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:0451d67c615c56d31c3689dd1c9aefa9d18c03f241199a0e3c470451666a1ab8"
|
||||
name = "github.com/rancher/go-rancher"
|
||||
packages = ["v2"]
|
||||
pruneopts = "UT"
|
||||
revision = "5d4e55e3f5de872bd5136d538139fffad238ad3a"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b24d38b282bacf9791408a080f606370efa3d364e4b5fd9ba0f7b87786d3b679"
|
||||
name = "github.com/urfave/cli"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
|
||||
version = "v1.20.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:3f3a05ae0b95893d90b9b3b5afdb79a9b3d96e4e36e099d841ae602e4aca0da8"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["ssh/terminal"]
|
||||
pruneopts = "UT"
|
||||
revision = "c126467f60eb25f8f27e5a981f32a87e3965053f"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:4a7c38ff146e5002dda78fdf599ac143fd0c98ffba9fb9d1721c3ba7fcd356c0"
|
||||
name = "golang.org/x/sys"
|
||||
packages = [
|
||||
"unix",
|
||||
"windows",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "3dc4335d56c789b04b0ba99b7a37249d9b614314"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/Sirupsen/logrus",
|
||||
"github.com/rancher/go-rancher/v2",
|
||||
"github.com/urfave/cli",
|
||||
]
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
#
|
||||
# [prune]
|
||||
# non-go = false
|
||||
# go-tests = true
|
||||
# unused-packages = true
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/Sirupsen/logrus"
|
||||
version = "1.0.6"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/rancher/go-rancher"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/urfave/cli"
|
||||
version = "1.20.0"
|
||||
|
||||
[prune]
|
||||
go-tests = true
|
||||
unused-packages = true
|
||||
@@ -1,12 +1,11 @@
|
||||
# drone-rancher
|
||||
|
||||
[](https://drone.seattleslow.com/josmo/drone-rancher)
|
||||
[](https://gitter.im/drone/drone)
|
||||
[](https://cloud.drone.io/josmo/drone-rancher)
|
||||
[](http://godoc.org/github.com/josmo/drone-rancher)
|
||||
[](https://goreportcard.com/report/github.com/josmo/drone-rancher)
|
||||
[](https://microbadger.com/images/peloton/drone-rancher "Get your own image badge on microbadger.com")
|
||||
[](https://microbadger.com/images/pelotech/drone-rancher "Get your own image badge on microbadger.com")
|
||||
|
||||
Drone plugin to deploy or update a project on Rancher. For the usage information and a listing of the available options please take a look at [the docs](DOCS.md).
|
||||
Drone plugin to deploy or update a project on Rancher 1.x only. For the usage information and a listing of the available options please take a look at [the docs](DOCS.md).
|
||||
|
||||
## Binary
|
||||
|
||||
@@ -31,5 +30,13 @@ docker run --rm \
|
||||
-e PLUGIN_DOCKER_IMAGE=<image> \
|
||||
-v $(pwd):$(pwd) \
|
||||
-w $(pwd) \
|
||||
peloton/drone-rancher
|
||||
pelotech/drone-rancher
|
||||
```
|
||||
|
||||
### Contribution
|
||||
|
||||
This repo is setup in a way that if you enable a personal drone server to build your fork it will
|
||||
build and publish your image (makes it easier to test PRs and use the image till the contributions get merged)
|
||||
|
||||
* Build local ```DRONE_REPO_OWNER=josmo DRONE_REPO_NAME=drone-rancher drone exec```
|
||||
* on your server just make sure you have DOCKER_USERNAME, DOCKER_PASSWORD, and PLUGIN_REPO set as secrets
|
||||
|
||||
@@ -8,21 +8,24 @@ import (
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
var build string // build number set at compile-time
|
||||
var (
|
||||
version = "0.0.0"
|
||||
build = "0"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "rancher publish"
|
||||
app.Usage = "rancher publish"
|
||||
app.Action = run
|
||||
app.Version = fmt.Sprintf("1.0.0+%s", build)
|
||||
app.Version = fmt.Sprintf("%s+%s", version, build)
|
||||
|
||||
app.Flags = []cli.Flag{
|
||||
|
||||
cli.StringFlag{
|
||||
Name: "url",
|
||||
Usage: "url to the rancher api",
|
||||
EnvVar: "PLUGIN_URL",
|
||||
EnvVar: "PLUGIN_URL, RANCHER_URL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "access-key",
|
||||
@@ -82,6 +85,11 @@ func main() {
|
||||
Usage: "Ensure the yaml was signed",
|
||||
EnvVar: "DRONE_YAML_VERIFIED",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "environment",
|
||||
Usage: "rancher environment to act on",
|
||||
EnvVar: "PLUGIN_ENVIRONMENT",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
@@ -103,6 +111,7 @@ func run(c *cli.Context) error {
|
||||
IntervalMillis: c.Int64("interval-millis"),
|
||||
BatchSize: c.Int64("batch-size"),
|
||||
YamlVerified: c.BoolT("yaml-verified"),
|
||||
Environment: c.String("environment"),
|
||||
}
|
||||
return plugin.Exec()
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ type Plugin struct {
|
||||
IntervalMillis int64
|
||||
BatchSize int64
|
||||
YamlVerified bool
|
||||
Environment string
|
||||
}
|
||||
|
||||
func (p *Plugin) Exec() error {
|
||||
@@ -53,10 +54,29 @@ func (p *Plugin) Exec() error {
|
||||
// Prepare service filters for service listing
|
||||
serviceFilters := map[string]interface{}{"name": wantedService}
|
||||
|
||||
if len(p.Environment) >= 1 {
|
||||
environments, err := rancher.Account.List(&client.ListOpts{Filters: map[string]interface{}{"name": p.Environment}})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to find given rancher environment: %s", err)
|
||||
}
|
||||
if len(environments.Data) <= 0 {
|
||||
return fmt.Errorf("Unable to find environment %s", p.Environment)
|
||||
}
|
||||
|
||||
// If found add environmentID to serviceFilters
|
||||
serviceFilters["accountId"] = environments.Data[0].Id
|
||||
}
|
||||
|
||||
// Query stacks with filter name=wantedStack
|
||||
if wantedStack != "" {
|
||||
stacks, err := rancher.Stack.List(&client.ListOpts{Filters: map[string]interface{}{"name": wantedStack}})
|
||||
|
||||
// If environment is defined re-query the API with the accountId
|
||||
if len(p.Environment) >= 1 {
|
||||
stacks, err = rancher.Stack.List(&client.ListOpts{Filters: map[string]interface{}{"accountId": serviceFilters["accountId"], "name": wantedStack}})
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to list rancher environments: %s", err)
|
||||
}
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
# 0.10.0
|
||||
|
||||
* feature: Add a test hook (#180)
|
||||
* feature: `ParseLevel` is now case-insensitive (#326)
|
||||
* feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308)
|
||||
* performance: avoid re-allocations on `WithFields` (#335)
|
||||
|
||||
# 0.9.0
|
||||
|
||||
* logrus/text_formatter: don't emit empty msg
|
||||
* logrus/hooks/airbrake: move out of main repository
|
||||
* logrus/hooks/sentry: move out of main repository
|
||||
* logrus/hooks/papertrail: move out of main repository
|
||||
* logrus/hooks/bugsnag: move out of main repository
|
||||
* logrus/core: run tests with `-race`
|
||||
* logrus/core: detect TTY based on `stderr`
|
||||
* logrus/core: support `WithError` on logger
|
||||
* logrus/core: Solaris support
|
||||
|
||||
# 0.8.7
|
||||
|
||||
* logrus/core: fix possible race (#216)
|
||||
* logrus/doc: small typo fixes and doc improvements
|
||||
|
||||
|
||||
# 0.8.6
|
||||
|
||||
* hooks/raven: allow passing an initialized client
|
||||
|
||||
# 0.8.5
|
||||
|
||||
* logrus/core: revert #208
|
||||
|
||||
# 0.8.4
|
||||
|
||||
* formatter/text: fix data race (#218)
|
||||
|
||||
# 0.8.3
|
||||
|
||||
* logrus/core: fix entry log level (#208)
|
||||
* logrus/core: improve performance of text formatter by 40%
|
||||
* logrus/core: expose `LevelHooks` type
|
||||
* logrus/core: add support for DragonflyBSD and NetBSD
|
||||
* formatter/text: print structs more verbosely
|
||||
|
||||
# 0.8.2
|
||||
|
||||
* logrus: fix more Fatal family functions
|
||||
|
||||
# 0.8.1
|
||||
|
||||
* logrus: fix not exiting on `Fatalf` and `Fatalln`
|
||||
|
||||
# 0.8.0
|
||||
|
||||
* logrus: defaults to stderr instead of stdout
|
||||
* hooks/sentry: add special field for `*http.Request`
|
||||
* formatter/text: ignore Windows for colors
|
||||
|
||||
# 0.7.3
|
||||
|
||||
* formatter/\*: allow configuration of timestamp layout
|
||||
|
||||
# 0.7.2
|
||||
|
||||
* formatter/text: Add configuration option for time format (#158)
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Simon Eskildsen
|
||||
|
||||
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.
|
||||
-388
@@ -1,388 +0,0 @@
|
||||
# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/> [](https://travis-ci.org/Sirupsen/logrus) [](https://godoc.org/github.com/Sirupsen/logrus)
|
||||
|
||||
Logrus is a structured logger for Go (golang), completely API compatible with
|
||||
the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not
|
||||
yet stable (pre 1.0). Logrus itself is completely stable and has been used in
|
||||
many large deployments. The core API is unlikely to change much but please
|
||||
version control your Logrus to make sure you aren't fetching latest `master` on
|
||||
every build.**
|
||||
|
||||
Nicely color-coded in development (when a TTY is attached, otherwise just
|
||||
plain text):
|
||||
|
||||

|
||||
|
||||
With `log.SetFormatter(&log.JSONFormatter{})`, for easy parsing by logstash
|
||||
or Splunk:
|
||||
|
||||
```json
|
||||
{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the
|
||||
ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"}
|
||||
|
||||
{"level":"warning","msg":"The group's number increased tremendously!",
|
||||
"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"}
|
||||
|
||||
{"animal":"walrus","level":"info","msg":"A giant walrus appears!",
|
||||
"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"}
|
||||
|
||||
{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.",
|
||||
"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"}
|
||||
|
||||
{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true,
|
||||
"time":"2014-03-10 19:57:38.562543128 -0400 EDT"}
|
||||
```
|
||||
|
||||
With the default `log.SetFormatter(&log.TextFormatter{})` when a TTY is not
|
||||
attached, the output is compatible with the
|
||||
[logfmt](http://godoc.org/github.com/kr/logfmt) format:
|
||||
|
||||
```text
|
||||
time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8
|
||||
time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
|
||||
time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true
|
||||
time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4
|
||||
time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009
|
||||
time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
|
||||
exit status 1
|
||||
```
|
||||
|
||||
#### Example
|
||||
|
||||
The simplest way to use Logrus is simply the package-level exported logger:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.WithFields(log.Fields{
|
||||
"animal": "walrus",
|
||||
}).Info("A walrus appears")
|
||||
}
|
||||
```
|
||||
|
||||
Note that it's completely api-compatible with the stdlib logger, so you can
|
||||
replace your `log` imports everywhere with `log "github.com/Sirupsen/logrus"`
|
||||
and you'll now have the flexibility of Logrus. You can customize it all you
|
||||
want:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Log as JSON instead of the default ASCII formatter.
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
|
||||
// Output to stderr instead of stdout, could also be a file.
|
||||
log.SetOutput(os.Stderr)
|
||||
|
||||
// Only log the warning severity or above.
|
||||
log.SetLevel(log.WarnLevel)
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.WithFields(log.Fields{
|
||||
"animal": "walrus",
|
||||
"size": 10,
|
||||
}).Info("A group of walrus emerges from the ocean")
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"omg": true,
|
||||
"number": 122,
|
||||
}).Warn("The group's number increased tremendously!")
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"omg": true,
|
||||
"number": 100,
|
||||
}).Fatal("The ice breaks!")
|
||||
|
||||
// A common pattern is to re-use fields between logging statements by re-using
|
||||
// the logrus.Entry returned from WithFields()
|
||||
contextLogger := log.WithFields(log.Fields{
|
||||
"common": "this is a common field",
|
||||
"other": "I also should be logged always",
|
||||
})
|
||||
|
||||
contextLogger.Info("I'll be logged with common and other field")
|
||||
contextLogger.Info("Me too")
|
||||
}
|
||||
```
|
||||
|
||||
For more advanced usage such as logging to multiple locations from the same
|
||||
application, you can also create an instance of the `logrus` Logger:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
// Create a new instance of the logger. You can have any number of instances.
|
||||
var log = logrus.New()
|
||||
|
||||
func main() {
|
||||
// The API for setting attributes is a little different than the package level
|
||||
// exported logger. See Godoc.
|
||||
log.Out = os.Stderr
|
||||
|
||||
log.WithFields(logrus.Fields{
|
||||
"animal": "walrus",
|
||||
"size": 10,
|
||||
}).Info("A group of walrus emerges from the ocean")
|
||||
}
|
||||
```
|
||||
|
||||
#### Fields
|
||||
|
||||
Logrus encourages careful, structured logging though logging fields instead of
|
||||
long, unparseable error messages. For example, instead of: `log.Fatalf("Failed
|
||||
to send event %s to topic %s with key %d")`, you should log the much more
|
||||
discoverable:
|
||||
|
||||
```go
|
||||
log.WithFields(log.Fields{
|
||||
"event": event,
|
||||
"topic": topic,
|
||||
"key": key,
|
||||
}).Fatal("Failed to send event")
|
||||
```
|
||||
|
||||
We've found this API forces you to think about logging in a way that produces
|
||||
much more useful logging messages. We've been in countless situations where just
|
||||
a single added field to a log statement that was already there would've saved us
|
||||
hours. The `WithFields` call is optional.
|
||||
|
||||
In general, with Logrus using any of the `printf`-family functions should be
|
||||
seen as a hint you should add a field, however, you can still use the
|
||||
`printf`-family functions with Logrus.
|
||||
|
||||
#### Hooks
|
||||
|
||||
You can add hooks for logging levels. For example to send errors to an exception
|
||||
tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to
|
||||
multiple places simultaneously, e.g. syslog.
|
||||
|
||||
Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in
|
||||
`init`:
|
||||
|
||||
```go
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake"
|
||||
logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
|
||||
"log/syslog"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
// Use the Airbrake hook to report errors that have Error severity or above to
|
||||
// an exception tracker. You can create custom hooks, see the Hooks section.
|
||||
log.AddHook(airbrake.NewHook(123, "xyz", "production"))
|
||||
|
||||
hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
|
||||
if err != nil {
|
||||
log.Error("Unable to connect to local syslog daemon")
|
||||
} else {
|
||||
log.AddHook(hook)
|
||||
}
|
||||
}
|
||||
```
|
||||
Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md).
|
||||
|
||||
| Hook | Description |
|
||||
| ----- | ----------- |
|
||||
| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. |
|
||||
| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. |
|
||||
| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. |
|
||||
| [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. |
|
||||
| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. |
|
||||
| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. |
|
||||
| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. |
|
||||
| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
|
||||
| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
|
||||
| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` |
|
||||
| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) |
|
||||
| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) |
|
||||
| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem |
|
||||
| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger |
|
||||
| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
|
||||
| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar |
|
||||
| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd |
|
||||
| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
|
||||
| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb |
|
||||
| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit |
|
||||
| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic |
|
||||
| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) |
|
||||
| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) |
|
||||
| [KafkaLogrus](https://github.com/goibibo/KafkaLogrus) | Hook for logging to kafka |
|
||||
| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) |
|
||||
| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch|
|
||||
|
||||
|
||||
#### Level logging
|
||||
|
||||
Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic.
|
||||
|
||||
```go
|
||||
log.Debug("Useful debugging information.")
|
||||
log.Info("Something noteworthy happened!")
|
||||
log.Warn("You should probably take a look at this.")
|
||||
log.Error("Something failed but I'm not quitting.")
|
||||
// Calls os.Exit(1) after logging
|
||||
log.Fatal("Bye.")
|
||||
// Calls panic() after logging
|
||||
log.Panic("I'm bailing.")
|
||||
```
|
||||
|
||||
You can set the logging level on a `Logger`, then it will only log entries with
|
||||
that severity or anything above it:
|
||||
|
||||
```go
|
||||
// Will log anything that is info or above (warn, error, fatal, panic). Default.
|
||||
log.SetLevel(log.InfoLevel)
|
||||
```
|
||||
|
||||
It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose
|
||||
environment if your application has that.
|
||||
|
||||
#### Entries
|
||||
|
||||
Besides the fields added with `WithField` or `WithFields` some fields are
|
||||
automatically added to all logging events:
|
||||
|
||||
1. `time`. The timestamp when the entry was created.
|
||||
2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after
|
||||
the `AddFields` call. E.g. `Failed to send event.`
|
||||
3. `level`. The logging level. E.g. `info`.
|
||||
|
||||
#### Environments
|
||||
|
||||
Logrus has no notion of environment.
|
||||
|
||||
If you wish for hooks and formatters to only be used in specific environments,
|
||||
you should handle that yourself. For example, if your application has a global
|
||||
variable `Environment`, which is a string representation of the environment you
|
||||
could do:
|
||||
|
||||
```go
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
init() {
|
||||
// do something here to set environment depending on an environment variable
|
||||
// or command-line flag
|
||||
if Environment == "production" {
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
} else {
|
||||
// The TextFormatter is default, you don't actually have to do this.
|
||||
log.SetFormatter(&log.TextFormatter{})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This configuration is how `logrus` was intended to be used, but JSON in
|
||||
production is mostly only useful if you do log aggregation with tools like
|
||||
Splunk or Logstash.
|
||||
|
||||
#### Formatters
|
||||
|
||||
The built-in logging formatters are:
|
||||
|
||||
* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise
|
||||
without colors.
|
||||
* *Note:* to force colored output when there is no TTY, set the `ForceColors`
|
||||
field to `true`. To force no colored output even if there is a TTY set the
|
||||
`DisableColors` field to `true`
|
||||
* `logrus.JSONFormatter`. Logs fields as JSON.
|
||||
* `logrus/formatters/logstash.LogstashFormatter`. Logs fields as [Logstash](http://logstash.net) Events.
|
||||
|
||||
```go
|
||||
logrus.SetFormatter(&logstash.LogstashFormatter{Type: "application_name"})
|
||||
```
|
||||
|
||||
Third party logging formatters:
|
||||
|
||||
* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout.
|
||||
* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦.
|
||||
|
||||
You can define your formatter by implementing the `Formatter` interface,
|
||||
requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a
|
||||
`Fields` type (`map[string]interface{}`) with all your fields as well as the
|
||||
default ones (see Entries section above):
|
||||
|
||||
```go
|
||||
type MyJSONFormatter struct {
|
||||
}
|
||||
|
||||
log.SetFormatter(new(MyJSONFormatter))
|
||||
|
||||
func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
// Note this doesn't include Time, Level and Message which are available on
|
||||
// the Entry. Consult `godoc` on information about those fields or read the
|
||||
// source of the official loggers.
|
||||
serialized, err := json.Marshal(entry.Data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
||||
}
|
||||
return append(serialized, '\n'), nil
|
||||
}
|
||||
```
|
||||
|
||||
#### Logger as an `io.Writer`
|
||||
|
||||
Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.
|
||||
|
||||
```go
|
||||
w := logger.Writer()
|
||||
defer w.Close()
|
||||
|
||||
srv := http.Server{
|
||||
// create a stdlib log.Logger that writes to
|
||||
// logrus.Logger.
|
||||
ErrorLog: log.New(w, "", 0),
|
||||
}
|
||||
```
|
||||
|
||||
Each line written to that writer will be printed the usual way, using formatters
|
||||
and hooks. The level for those entries is `info`.
|
||||
|
||||
#### Rotation
|
||||
|
||||
Log rotation is not provided with Logrus. Log rotation should be done by an
|
||||
external program (like `logrotate(8)`) that can compress and delete old log
|
||||
entries. It should not be a feature of the application-level logger.
|
||||
|
||||
#### Tools
|
||||
|
||||
| Tool | Description |
|
||||
| ---- | ----------- |
|
||||
|[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.|
|
||||
|
||||
#### Testing
|
||||
|
||||
Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides:
|
||||
|
||||
* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just add the `test` hook
|
||||
* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any):
|
||||
|
||||
```go
|
||||
logger, hook := NewNullLogger()
|
||||
logger.Error("Hello error")
|
||||
|
||||
assert.Equal(1, len(hook.Entries))
|
||||
assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
|
||||
assert.Equal("Hello error", hook.LastEntry().Message)
|
||||
|
||||
hook.Reset()
|
||||
assert.Nil(hook.LastEntry())
|
||||
```
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
|
||||
|
||||
|
||||
The simplest way to use Logrus is simply the package-level exported logger:
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.WithFields(log.Fields{
|
||||
"animal": "walrus",
|
||||
"number": 1,
|
||||
"size": 10,
|
||||
}).Info("A walrus appears")
|
||||
}
|
||||
|
||||
Output:
|
||||
time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
|
||||
|
||||
For a full guide visit https://github.com/Sirupsen/logrus
|
||||
*/
|
||||
package logrus
|
||||
-264
@@ -1,264 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Defines the key when adding errors using WithError.
|
||||
var ErrorKey = "error"
|
||||
|
||||
// An entry is the final or intermediate Logrus logging entry. It contains all
|
||||
// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
|
||||
// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
|
||||
// passed around as much as you wish to avoid field duplication.
|
||||
type Entry struct {
|
||||
Logger *Logger
|
||||
|
||||
// Contains all the fields set by the user.
|
||||
Data Fields
|
||||
|
||||
// Time at which the log entry was created
|
||||
Time time.Time
|
||||
|
||||
// Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic
|
||||
Level Level
|
||||
|
||||
// Message passed to Debug, Info, Warn, Error, Fatal or Panic
|
||||
Message string
|
||||
}
|
||||
|
||||
func NewEntry(logger *Logger) *Entry {
|
||||
return &Entry{
|
||||
Logger: logger,
|
||||
// Default is three fields, give a little extra room
|
||||
Data: make(Fields, 5),
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a reader for the entry, which is a proxy to the formatter.
|
||||
func (entry *Entry) Reader() (*bytes.Buffer, error) {
|
||||
serialized, err := entry.Logger.Formatter.Format(entry)
|
||||
return bytes.NewBuffer(serialized), err
|
||||
}
|
||||
|
||||
// Returns the string representation from the reader and ultimately the
|
||||
// formatter.
|
||||
func (entry *Entry) String() (string, error) {
|
||||
reader, err := entry.Reader()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return reader.String(), err
|
||||
}
|
||||
|
||||
// Add an error as single field (using the key defined in ErrorKey) to the Entry.
|
||||
func (entry *Entry) WithError(err error) *Entry {
|
||||
return entry.WithField(ErrorKey, err)
|
||||
}
|
||||
|
||||
// Add a single field to the Entry.
|
||||
func (entry *Entry) WithField(key string, value interface{}) *Entry {
|
||||
return entry.WithFields(Fields{key: value})
|
||||
}
|
||||
|
||||
// Add a map of fields to the Entry.
|
||||
func (entry *Entry) WithFields(fields Fields) *Entry {
|
||||
data := make(Fields, len(entry.Data)+len(fields))
|
||||
for k, v := range entry.Data {
|
||||
data[k] = v
|
||||
}
|
||||
for k, v := range fields {
|
||||
data[k] = v
|
||||
}
|
||||
return &Entry{Logger: entry.Logger, Data: data}
|
||||
}
|
||||
|
||||
// This function is not declared with a pointer value because otherwise
|
||||
// race conditions will occur when using multiple goroutines
|
||||
func (entry Entry) log(level Level, msg string) {
|
||||
entry.Time = time.Now()
|
||||
entry.Level = level
|
||||
entry.Message = msg
|
||||
|
||||
if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
|
||||
entry.Logger.mu.Lock()
|
||||
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
|
||||
entry.Logger.mu.Unlock()
|
||||
}
|
||||
|
||||
reader, err := entry.Reader()
|
||||
if err != nil {
|
||||
entry.Logger.mu.Lock()
|
||||
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
|
||||
entry.Logger.mu.Unlock()
|
||||
}
|
||||
|
||||
entry.Logger.mu.Lock()
|
||||
defer entry.Logger.mu.Unlock()
|
||||
|
||||
_, err = io.Copy(entry.Logger.Out, reader)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
|
||||
}
|
||||
|
||||
// To avoid Entry#log() returning a value that only would make sense for
|
||||
// panic() to use in Entry#Panic(), we avoid the allocation by checking
|
||||
// directly here.
|
||||
if level <= PanicLevel {
|
||||
panic(&entry)
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Debug(args ...interface{}) {
|
||||
if entry.Logger.Level >= DebugLevel {
|
||||
entry.log(DebugLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Print(args ...interface{}) {
|
||||
entry.Info(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Info(args ...interface{}) {
|
||||
if entry.Logger.Level >= InfoLevel {
|
||||
entry.log(InfoLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warn(args ...interface{}) {
|
||||
if entry.Logger.Level >= WarnLevel {
|
||||
entry.log(WarnLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warning(args ...interface{}) {
|
||||
entry.Warn(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Error(args ...interface{}) {
|
||||
if entry.Logger.Level >= ErrorLevel {
|
||||
entry.log(ErrorLevel, fmt.Sprint(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Fatal(args ...interface{}) {
|
||||
if entry.Logger.Level >= FatalLevel {
|
||||
entry.log(FatalLevel, fmt.Sprint(args...))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (entry *Entry) Panic(args ...interface{}) {
|
||||
if entry.Logger.Level >= PanicLevel {
|
||||
entry.log(PanicLevel, fmt.Sprint(args...))
|
||||
}
|
||||
panic(fmt.Sprint(args...))
|
||||
}
|
||||
|
||||
// Entry Printf family functions
|
||||
|
||||
func (entry *Entry) Debugf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= DebugLevel {
|
||||
entry.Debug(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Infof(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= InfoLevel {
|
||||
entry.Info(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Printf(format string, args ...interface{}) {
|
||||
entry.Infof(format, args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Warnf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= WarnLevel {
|
||||
entry.Warn(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warningf(format string, args ...interface{}) {
|
||||
entry.Warnf(format, args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Errorf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= ErrorLevel {
|
||||
entry.Error(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Fatalf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= FatalLevel {
|
||||
entry.Fatal(fmt.Sprintf(format, args...))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (entry *Entry) Panicf(format string, args ...interface{}) {
|
||||
if entry.Logger.Level >= PanicLevel {
|
||||
entry.Panic(fmt.Sprintf(format, args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Entry Println family functions
|
||||
|
||||
func (entry *Entry) Debugln(args ...interface{}) {
|
||||
if entry.Logger.Level >= DebugLevel {
|
||||
entry.Debug(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Infoln(args ...interface{}) {
|
||||
if entry.Logger.Level >= InfoLevel {
|
||||
entry.Info(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Println(args ...interface{}) {
|
||||
entry.Infoln(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Warnln(args ...interface{}) {
|
||||
if entry.Logger.Level >= WarnLevel {
|
||||
entry.Warn(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Warningln(args ...interface{}) {
|
||||
entry.Warnln(args...)
|
||||
}
|
||||
|
||||
func (entry *Entry) Errorln(args ...interface{}) {
|
||||
if entry.Logger.Level >= ErrorLevel {
|
||||
entry.Error(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Fatalln(args ...interface{}) {
|
||||
if entry.Logger.Level >= FatalLevel {
|
||||
entry.Fatal(entry.sprintlnn(args...))
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (entry *Entry) Panicln(args ...interface{}) {
|
||||
if entry.Logger.Level >= PanicLevel {
|
||||
entry.Panic(entry.sprintlnn(args...))
|
||||
}
|
||||
}
|
||||
|
||||
// Sprintlnn => Sprint no newline. This is to get the behavior of how
|
||||
// fmt.Sprintln where spaces are always added between operands, regardless of
|
||||
// their type. Instead of vendoring the Sprintln implementation to spare a
|
||||
// string allocation, we do the simplest thing.
|
||||
func (entry *Entry) sprintlnn(args ...interface{}) string {
|
||||
msg := fmt.Sprintln(args...)
|
||||
return msg[:len(msg)-1]
|
||||
}
|
||||
-193
@@ -1,193 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
var (
|
||||
// std is the name of the standard logger in stdlib `log`
|
||||
std = New()
|
||||
)
|
||||
|
||||
func StandardLogger() *Logger {
|
||||
return std
|
||||
}
|
||||
|
||||
// SetOutput sets the standard logger output.
|
||||
func SetOutput(out io.Writer) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Out = out
|
||||
}
|
||||
|
||||
// SetFormatter sets the standard logger formatter.
|
||||
func SetFormatter(formatter Formatter) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Formatter = formatter
|
||||
}
|
||||
|
||||
// SetLevel sets the standard logger level.
|
||||
func SetLevel(level Level) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Level = level
|
||||
}
|
||||
|
||||
// GetLevel returns the standard logger level.
|
||||
func GetLevel() Level {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
return std.Level
|
||||
}
|
||||
|
||||
// AddHook adds a hook to the standard logger hooks.
|
||||
func AddHook(hook Hook) {
|
||||
std.mu.Lock()
|
||||
defer std.mu.Unlock()
|
||||
std.Hooks.Add(hook)
|
||||
}
|
||||
|
||||
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
|
||||
func WithError(err error) *Entry {
|
||||
return std.WithField(ErrorKey, err)
|
||||
}
|
||||
|
||||
// WithField creates an entry from the standard logger and adds a field to
|
||||
// it. If you want multiple fields, use `WithFields`.
|
||||
//
|
||||
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
|
||||
// or Panic on the Entry it returns.
|
||||
func WithField(key string, value interface{}) *Entry {
|
||||
return std.WithField(key, value)
|
||||
}
|
||||
|
||||
// WithFields creates an entry from the standard logger and adds multiple
|
||||
// fields to it. This is simply a helper for `WithField`, invoking it
|
||||
// once for each field.
|
||||
//
|
||||
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
|
||||
// or Panic on the Entry it returns.
|
||||
func WithFields(fields Fields) *Entry {
|
||||
return std.WithFields(fields)
|
||||
}
|
||||
|
||||
// Debug logs a message at level Debug on the standard logger.
|
||||
func Debug(args ...interface{}) {
|
||||
std.Debug(args...)
|
||||
}
|
||||
|
||||
// Print logs a message at level Info on the standard logger.
|
||||
func Print(args ...interface{}) {
|
||||
std.Print(args...)
|
||||
}
|
||||
|
||||
// Info logs a message at level Info on the standard logger.
|
||||
func Info(args ...interface{}) {
|
||||
std.Info(args...)
|
||||
}
|
||||
|
||||
// Warn logs a message at level Warn on the standard logger.
|
||||
func Warn(args ...interface{}) {
|
||||
std.Warn(args...)
|
||||
}
|
||||
|
||||
// Warning logs a message at level Warn on the standard logger.
|
||||
func Warning(args ...interface{}) {
|
||||
std.Warning(args...)
|
||||
}
|
||||
|
||||
// Error logs a message at level Error on the standard logger.
|
||||
func Error(args ...interface{}) {
|
||||
std.Error(args...)
|
||||
}
|
||||
|
||||
// Panic logs a message at level Panic on the standard logger.
|
||||
func Panic(args ...interface{}) {
|
||||
std.Panic(args...)
|
||||
}
|
||||
|
||||
// Fatal logs a message at level Fatal on the standard logger.
|
||||
func Fatal(args ...interface{}) {
|
||||
std.Fatal(args...)
|
||||
}
|
||||
|
||||
// Debugf logs a message at level Debug on the standard logger.
|
||||
func Debugf(format string, args ...interface{}) {
|
||||
std.Debugf(format, args...)
|
||||
}
|
||||
|
||||
// Printf logs a message at level Info on the standard logger.
|
||||
func Printf(format string, args ...interface{}) {
|
||||
std.Printf(format, args...)
|
||||
}
|
||||
|
||||
// Infof logs a message at level Info on the standard logger.
|
||||
func Infof(format string, args ...interface{}) {
|
||||
std.Infof(format, args...)
|
||||
}
|
||||
|
||||
// Warnf logs a message at level Warn on the standard logger.
|
||||
func Warnf(format string, args ...interface{}) {
|
||||
std.Warnf(format, args...)
|
||||
}
|
||||
|
||||
// Warningf logs a message at level Warn on the standard logger.
|
||||
func Warningf(format string, args ...interface{}) {
|
||||
std.Warningf(format, args...)
|
||||
}
|
||||
|
||||
// Errorf logs a message at level Error on the standard logger.
|
||||
func Errorf(format string, args ...interface{}) {
|
||||
std.Errorf(format, args...)
|
||||
}
|
||||
|
||||
// Panicf logs a message at level Panic on the standard logger.
|
||||
func Panicf(format string, args ...interface{}) {
|
||||
std.Panicf(format, args...)
|
||||
}
|
||||
|
||||
// Fatalf logs a message at level Fatal on the standard logger.
|
||||
func Fatalf(format string, args ...interface{}) {
|
||||
std.Fatalf(format, args...)
|
||||
}
|
||||
|
||||
// Debugln logs a message at level Debug on the standard logger.
|
||||
func Debugln(args ...interface{}) {
|
||||
std.Debugln(args...)
|
||||
}
|
||||
|
||||
// Println logs a message at level Info on the standard logger.
|
||||
func Println(args ...interface{}) {
|
||||
std.Println(args...)
|
||||
}
|
||||
|
||||
// Infoln logs a message at level Info on the standard logger.
|
||||
func Infoln(args ...interface{}) {
|
||||
std.Infoln(args...)
|
||||
}
|
||||
|
||||
// Warnln logs a message at level Warn on the standard logger.
|
||||
func Warnln(args ...interface{}) {
|
||||
std.Warnln(args...)
|
||||
}
|
||||
|
||||
// Warningln logs a message at level Warn on the standard logger.
|
||||
func Warningln(args ...interface{}) {
|
||||
std.Warningln(args...)
|
||||
}
|
||||
|
||||
// Errorln logs a message at level Error on the standard logger.
|
||||
func Errorln(args ...interface{}) {
|
||||
std.Errorln(args...)
|
||||
}
|
||||
|
||||
// Panicln logs a message at level Panic on the standard logger.
|
||||
func Panicln(args ...interface{}) {
|
||||
std.Panicln(args...)
|
||||
}
|
||||
|
||||
// Fatalln logs a message at level Fatal on the standard logger.
|
||||
func Fatalln(args ...interface{}) {
|
||||
std.Fatalln(args...)
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import "time"
|
||||
|
||||
const DefaultTimestampFormat = time.RFC3339
|
||||
|
||||
// The Formatter interface is used to implement a custom Formatter. It takes an
|
||||
// `Entry`. It exposes all the fields, including the default ones:
|
||||
//
|
||||
// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
|
||||
// * `entry.Data["time"]`. The timestamp.
|
||||
// * `entry.Data["level"]. The level the entry was logged at.
|
||||
//
|
||||
// Any additional fields added with `WithField` or `WithFields` are also in
|
||||
// `entry.Data`. Format is expected to return an array of bytes which are then
|
||||
// logged to `logger.Out`.
|
||||
type Formatter interface {
|
||||
Format(*Entry) ([]byte, error)
|
||||
}
|
||||
|
||||
// This is to not silently overwrite `time`, `msg` and `level` fields when
|
||||
// dumping it. If this code wasn't there doing:
|
||||
//
|
||||
// logrus.WithField("level", 1).Info("hello")
|
||||
//
|
||||
// Would just silently drop the user provided level. Instead with this code
|
||||
// it'll logged as:
|
||||
//
|
||||
// {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
|
||||
//
|
||||
// It's not exported because it's still using Data in an opinionated way. It's to
|
||||
// avoid code duplication between the two default formatters.
|
||||
func prefixFieldClashes(data Fields) {
|
||||
_, ok := data["time"]
|
||||
if ok {
|
||||
data["fields.time"] = data["time"]
|
||||
}
|
||||
|
||||
_, ok = data["msg"]
|
||||
if ok {
|
||||
data["fields.msg"] = data["msg"]
|
||||
}
|
||||
|
||||
_, ok = data["level"]
|
||||
if ok {
|
||||
data["fields.level"] = data["level"]
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package logrus
|
||||
|
||||
// A hook to be fired when logging on the logging levels returned from
|
||||
// `Levels()` on your implementation of the interface. Note that this is not
|
||||
// fired in a goroutine or a channel with workers, you should handle such
|
||||
// functionality yourself if your call is non-blocking and you don't wish for
|
||||
// the logging calls for levels returned from `Levels()` to block.
|
||||
type Hook interface {
|
||||
Levels() []Level
|
||||
Fire(*Entry) error
|
||||
}
|
||||
|
||||
// Internal type for storing the hooks on a logger instance.
|
||||
type LevelHooks map[Level][]Hook
|
||||
|
||||
// Add a hook to an instance of logger. This is called with
|
||||
// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
|
||||
func (hooks LevelHooks) Add(hook Hook) {
|
||||
for _, level := range hook.Levels() {
|
||||
hooks[level] = append(hooks[level], hook)
|
||||
}
|
||||
}
|
||||
|
||||
// Fire all the hooks for the passed level. Used by `entry.log` to fire
|
||||
// appropriate hooks for a log entry.
|
||||
func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
|
||||
for _, hook := range hooks[level] {
|
||||
if err := hook.Fire(entry); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type JSONFormatter struct {
|
||||
// TimestampFormat sets the format used for marshaling timestamps.
|
||||
TimestampFormat string
|
||||
}
|
||||
|
||||
func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
data := make(Fields, len(entry.Data)+3)
|
||||
for k, v := range entry.Data {
|
||||
switch v := v.(type) {
|
||||
case error:
|
||||
// Otherwise errors are ignored by `encoding/json`
|
||||
// https://github.com/Sirupsen/logrus/issues/137
|
||||
data[k] = v.Error()
|
||||
default:
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
prefixFieldClashes(data)
|
||||
|
||||
timestampFormat := f.TimestampFormat
|
||||
if timestampFormat == "" {
|
||||
timestampFormat = DefaultTimestampFormat
|
||||
}
|
||||
|
||||
data["time"] = entry.Time.Format(timestampFormat)
|
||||
data["msg"] = entry.Message
|
||||
data["level"] = entry.Level.String()
|
||||
|
||||
serialized, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
||||
}
|
||||
return append(serialized, '\n'), nil
|
||||
}
|
||||
-212
@@ -1,212 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Logger struct {
|
||||
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
|
||||
// file, or leave it default which is `os.Stderr`. You can also set this to
|
||||
// something more adventorous, such as logging to Kafka.
|
||||
Out io.Writer
|
||||
// Hooks for the logger instance. These allow firing events based on logging
|
||||
// levels and log entries. For example, to send errors to an error tracking
|
||||
// service, log to StatsD or dump the core on fatal errors.
|
||||
Hooks LevelHooks
|
||||
// All log entries pass through the formatter before logged to Out. The
|
||||
// included formatters are `TextFormatter` and `JSONFormatter` for which
|
||||
// TextFormatter is the default. In development (when a TTY is attached) it
|
||||
// logs with colors, but to a file it wouldn't. You can easily implement your
|
||||
// own that implements the `Formatter` interface, see the `README` or included
|
||||
// formatters for examples.
|
||||
Formatter Formatter
|
||||
// The logging level the logger should log at. This is typically (and defaults
|
||||
// to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be
|
||||
// logged. `logrus.Debug` is useful in
|
||||
Level Level
|
||||
// Used to sync writing to the log.
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// Creates a new logger. Configuration should be set by changing `Formatter`,
|
||||
// `Out` and `Hooks` directly on the default logger instance. You can also just
|
||||
// instantiate your own:
|
||||
//
|
||||
// var log = &Logger{
|
||||
// Out: os.Stderr,
|
||||
// Formatter: new(JSONFormatter),
|
||||
// Hooks: make(LevelHooks),
|
||||
// Level: logrus.DebugLevel,
|
||||
// }
|
||||
//
|
||||
// It's recommended to make this a global instance called `log`.
|
||||
func New() *Logger {
|
||||
return &Logger{
|
||||
Out: os.Stderr,
|
||||
Formatter: new(TextFormatter),
|
||||
Hooks: make(LevelHooks),
|
||||
Level: InfoLevel,
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a field to the log entry, note that you it doesn't log until you call
|
||||
// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
|
||||
// If you want multiple fields, use `WithFields`.
|
||||
func (logger *Logger) WithField(key string, value interface{}) *Entry {
|
||||
return NewEntry(logger).WithField(key, value)
|
||||
}
|
||||
|
||||
// Adds a struct of fields to the log entry. All it does is call `WithField` for
|
||||
// each `Field`.
|
||||
func (logger *Logger) WithFields(fields Fields) *Entry {
|
||||
return NewEntry(logger).WithFields(fields)
|
||||
}
|
||||
|
||||
// Add an error as single field to the log entry. All it does is call
|
||||
// `WithError` for the given `error`.
|
||||
func (logger *Logger) WithError(err error) *Entry {
|
||||
return NewEntry(logger).WithError(err)
|
||||
}
|
||||
|
||||
func (logger *Logger) Debugf(format string, args ...interface{}) {
|
||||
if logger.Level >= DebugLevel {
|
||||
NewEntry(logger).Debugf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Infof(format string, args ...interface{}) {
|
||||
if logger.Level >= InfoLevel {
|
||||
NewEntry(logger).Infof(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Printf(format string, args ...interface{}) {
|
||||
NewEntry(logger).Printf(format, args...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warnf(format string, args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Warningf(format string, args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Errorf(format string, args ...interface{}) {
|
||||
if logger.Level >= ErrorLevel {
|
||||
NewEntry(logger).Errorf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatalf(format string, args ...interface{}) {
|
||||
if logger.Level >= FatalLevel {
|
||||
NewEntry(logger).Fatalf(format, args...)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (logger *Logger) Panicf(format string, args ...interface{}) {
|
||||
if logger.Level >= PanicLevel {
|
||||
NewEntry(logger).Panicf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Debug(args ...interface{}) {
|
||||
if logger.Level >= DebugLevel {
|
||||
NewEntry(logger).Debug(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Info(args ...interface{}) {
|
||||
if logger.Level >= InfoLevel {
|
||||
NewEntry(logger).Info(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Print(args ...interface{}) {
|
||||
NewEntry(logger).Info(args...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warn(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warn(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Warning(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warn(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Error(args ...interface{}) {
|
||||
if logger.Level >= ErrorLevel {
|
||||
NewEntry(logger).Error(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatal(args ...interface{}) {
|
||||
if logger.Level >= FatalLevel {
|
||||
NewEntry(logger).Fatal(args...)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (logger *Logger) Panic(args ...interface{}) {
|
||||
if logger.Level >= PanicLevel {
|
||||
NewEntry(logger).Panic(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Debugln(args ...interface{}) {
|
||||
if logger.Level >= DebugLevel {
|
||||
NewEntry(logger).Debugln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Infoln(args ...interface{}) {
|
||||
if logger.Level >= InfoLevel {
|
||||
NewEntry(logger).Infoln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Println(args ...interface{}) {
|
||||
NewEntry(logger).Println(args...)
|
||||
}
|
||||
|
||||
func (logger *Logger) Warnln(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Warningln(args ...interface{}) {
|
||||
if logger.Level >= WarnLevel {
|
||||
NewEntry(logger).Warnln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Errorln(args ...interface{}) {
|
||||
if logger.Level >= ErrorLevel {
|
||||
NewEntry(logger).Errorln(args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (logger *Logger) Fatalln(args ...interface{}) {
|
||||
if logger.Level >= FatalLevel {
|
||||
NewEntry(logger).Fatalln(args...)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func (logger *Logger) Panicln(args ...interface{}) {
|
||||
if logger.Level >= PanicLevel {
|
||||
NewEntry(logger).Panicln(args...)
|
||||
}
|
||||
}
|
||||
-143
@@ -1,143 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Fields type, used to pass to `WithFields`.
|
||||
type Fields map[string]interface{}
|
||||
|
||||
// Level type
|
||||
type Level uint8
|
||||
|
||||
// Convert the Level to a string. E.g. PanicLevel becomes "panic".
|
||||
func (level Level) String() string {
|
||||
switch level {
|
||||
case DebugLevel:
|
||||
return "debug"
|
||||
case InfoLevel:
|
||||
return "info"
|
||||
case WarnLevel:
|
||||
return "warning"
|
||||
case ErrorLevel:
|
||||
return "error"
|
||||
case FatalLevel:
|
||||
return "fatal"
|
||||
case PanicLevel:
|
||||
return "panic"
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
// ParseLevel takes a string level and returns the Logrus log level constant.
|
||||
func ParseLevel(lvl string) (Level, error) {
|
||||
switch strings.ToLower(lvl) {
|
||||
case "panic":
|
||||
return PanicLevel, nil
|
||||
case "fatal":
|
||||
return FatalLevel, nil
|
||||
case "error":
|
||||
return ErrorLevel, nil
|
||||
case "warn", "warning":
|
||||
return WarnLevel, nil
|
||||
case "info":
|
||||
return InfoLevel, nil
|
||||
case "debug":
|
||||
return DebugLevel, nil
|
||||
}
|
||||
|
||||
var l Level
|
||||
return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
|
||||
}
|
||||
|
||||
// A constant exposing all logging levels
|
||||
var AllLevels = []Level{
|
||||
PanicLevel,
|
||||
FatalLevel,
|
||||
ErrorLevel,
|
||||
WarnLevel,
|
||||
InfoLevel,
|
||||
DebugLevel,
|
||||
}
|
||||
|
||||
// These are the different logging levels. You can set the logging level to log
|
||||
// on your instance of logger, obtained with `logrus.New()`.
|
||||
const (
|
||||
// PanicLevel level, highest level of severity. Logs and then calls panic with the
|
||||
// message passed to Debug, Info, ...
|
||||
PanicLevel Level = iota
|
||||
// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
|
||||
// logging level is set to Panic.
|
||||
FatalLevel
|
||||
// ErrorLevel level. Logs. Used for errors that should definitely be noted.
|
||||
// Commonly used for hooks to send errors to an error tracking service.
|
||||
ErrorLevel
|
||||
// WarnLevel level. Non-critical entries that deserve eyes.
|
||||
WarnLevel
|
||||
// InfoLevel level. General operational entries about what's going on inside the
|
||||
// application.
|
||||
InfoLevel
|
||||
// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
|
||||
DebugLevel
|
||||
)
|
||||
|
||||
// Won't compile if StdLogger can't be realized by a log.Logger
|
||||
var (
|
||||
_ StdLogger = &log.Logger{}
|
||||
_ StdLogger = &Entry{}
|
||||
_ StdLogger = &Logger{}
|
||||
)
|
||||
|
||||
// StdLogger is what your logrus-enabled library should take, that way
|
||||
// it'll accept a stdlib logger and a logrus logger. There's no standard
|
||||
// interface, this is the closest we get, unfortunately.
|
||||
type StdLogger interface {
|
||||
Print(...interface{})
|
||||
Printf(string, ...interface{})
|
||||
Println(...interface{})
|
||||
|
||||
Fatal(...interface{})
|
||||
Fatalf(string, ...interface{})
|
||||
Fatalln(...interface{})
|
||||
|
||||
Panic(...interface{})
|
||||
Panicf(string, ...interface{})
|
||||
Panicln(...interface{})
|
||||
}
|
||||
|
||||
// The FieldLogger interface generalizes the Entry and Logger types
|
||||
type FieldLogger interface {
|
||||
WithField(key string, value interface{}) *Entry
|
||||
WithFields(fields Fields) *Entry
|
||||
WithError(err error) *Entry
|
||||
|
||||
Debugf(format string, args ...interface{})
|
||||
Infof(format string, args ...interface{})
|
||||
Printf(format string, args ...interface{})
|
||||
Warnf(format string, args ...interface{})
|
||||
Warningf(format string, args ...interface{})
|
||||
Errorf(format string, args ...interface{})
|
||||
Fatalf(format string, args ...interface{})
|
||||
Panicf(format string, args ...interface{})
|
||||
|
||||
Debug(args ...interface{})
|
||||
Info(args ...interface{})
|
||||
Print(args ...interface{})
|
||||
Warn(args ...interface{})
|
||||
Warning(args ...interface{})
|
||||
Error(args ...interface{})
|
||||
Fatal(args ...interface{})
|
||||
Panic(args ...interface{})
|
||||
|
||||
Debugln(args ...interface{})
|
||||
Infoln(args ...interface{})
|
||||
Println(args ...interface{})
|
||||
Warnln(args ...interface{})
|
||||
Warningln(args ...interface{})
|
||||
Errorln(args ...interface{})
|
||||
Fatalln(args ...interface{})
|
||||
Panicln(args ...interface{})
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// +build darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
package logrus
|
||||
|
||||
import "syscall"
|
||||
|
||||
const ioctlReadTermios = syscall.TIOCGETA
|
||||
|
||||
type Termios syscall.Termios
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// Based on ssh/terminal:
|
||||
// Copyright 2013 The Go 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 logrus
|
||||
|
||||
import "syscall"
|
||||
|
||||
const ioctlReadTermios = syscall.TCGETS
|
||||
|
||||
type Termios syscall.Termios
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// Based on ssh/terminal:
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build linux darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// IsTerminal returns true if stderr's file descriptor is a terminal.
|
||||
func IsTerminal() bool {
|
||||
fd := syscall.Stderr
|
||||
var termios Termios
|
||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
||||
return err == 0
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// +build solaris
|
||||
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||
func IsTerminal() bool {
|
||||
_, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
|
||||
return err == nil
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// Based on ssh/terminal:
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build windows
|
||||
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||
|
||||
var (
|
||||
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
||||
)
|
||||
|
||||
// IsTerminal returns true if stderr's file descriptor is a terminal.
|
||||
func IsTerminal() bool {
|
||||
fd := syscall.Stderr
|
||||
var st uint32
|
||||
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
|
||||
return r != 0 && e == 0
|
||||
}
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
nocolor = 0
|
||||
red = 31
|
||||
green = 32
|
||||
yellow = 33
|
||||
blue = 34
|
||||
gray = 37
|
||||
)
|
||||
|
||||
var (
|
||||
baseTimestamp time.Time
|
||||
isTerminal bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
baseTimestamp = time.Now()
|
||||
isTerminal = IsTerminal()
|
||||
}
|
||||
|
||||
func miniTS() int {
|
||||
return int(time.Since(baseTimestamp) / time.Second)
|
||||
}
|
||||
|
||||
type TextFormatter struct {
|
||||
// Set to true to bypass checking for a TTY before outputting colors.
|
||||
ForceColors bool
|
||||
|
||||
// Force disabling colors.
|
||||
DisableColors bool
|
||||
|
||||
// Disable timestamp logging. useful when output is redirected to logging
|
||||
// system that already adds timestamps.
|
||||
DisableTimestamp bool
|
||||
|
||||
// Enable logging the full timestamp when a TTY is attached instead of just
|
||||
// the time passed since beginning of execution.
|
||||
FullTimestamp bool
|
||||
|
||||
// TimestampFormat to use for display when a full timestamp is printed
|
||||
TimestampFormat string
|
||||
|
||||
// The fields are sorted by default for a consistent output. For applications
|
||||
// that log extremely frequently and don't use the JSON formatter this may not
|
||||
// be desired.
|
||||
DisableSorting bool
|
||||
}
|
||||
|
||||
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
var keys []string = make([]string, 0, len(entry.Data))
|
||||
for k := range entry.Data {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
if !f.DisableSorting {
|
||||
sort.Strings(keys)
|
||||
}
|
||||
|
||||
b := &bytes.Buffer{}
|
||||
|
||||
prefixFieldClashes(entry.Data)
|
||||
|
||||
isColorTerminal := isTerminal && (runtime.GOOS != "windows")
|
||||
isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors
|
||||
|
||||
timestampFormat := f.TimestampFormat
|
||||
if timestampFormat == "" {
|
||||
timestampFormat = DefaultTimestampFormat
|
||||
}
|
||||
if isColored {
|
||||
f.printColored(b, entry, keys, timestampFormat)
|
||||
} else {
|
||||
if !f.DisableTimestamp {
|
||||
f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat))
|
||||
}
|
||||
f.appendKeyValue(b, "level", entry.Level.String())
|
||||
if entry.Message != "" {
|
||||
f.appendKeyValue(b, "msg", entry.Message)
|
||||
}
|
||||
for _, key := range keys {
|
||||
f.appendKeyValue(b, key, entry.Data[key])
|
||||
}
|
||||
}
|
||||
|
||||
b.WriteByte('\n')
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) {
|
||||
var levelColor int
|
||||
switch entry.Level {
|
||||
case DebugLevel:
|
||||
levelColor = gray
|
||||
case WarnLevel:
|
||||
levelColor = yellow
|
||||
case ErrorLevel, FatalLevel, PanicLevel:
|
||||
levelColor = red
|
||||
default:
|
||||
levelColor = blue
|
||||
}
|
||||
|
||||
levelText := strings.ToUpper(entry.Level.String())[0:4]
|
||||
|
||||
if !f.FullTimestamp {
|
||||
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message)
|
||||
} else {
|
||||
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message)
|
||||
}
|
||||
for _, k := range keys {
|
||||
v := entry.Data[k]
|
||||
fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
func needsQuoting(text string) bool {
|
||||
for _, ch := range text {
|
||||
if !((ch >= 'a' && ch <= 'z') ||
|
||||
(ch >= 'A' && ch <= 'Z') ||
|
||||
(ch >= '0' && ch <= '9') ||
|
||||
ch == '-' || ch == '.') {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
|
||||
|
||||
b.WriteString(key)
|
||||
b.WriteByte('=')
|
||||
|
||||
switch value := value.(type) {
|
||||
case string:
|
||||
if needsQuoting(value) {
|
||||
b.WriteString(value)
|
||||
} else {
|
||||
fmt.Fprintf(b, "%q", value)
|
||||
}
|
||||
case error:
|
||||
errmsg := value.Error()
|
||||
if needsQuoting(errmsg) {
|
||||
b.WriteString(errmsg)
|
||||
} else {
|
||||
fmt.Fprintf(b, "%q", value)
|
||||
}
|
||||
default:
|
||||
fmt.Fprint(b, value)
|
||||
}
|
||||
|
||||
b.WriteByte(' ')
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func (logger *Logger) Writer() *io.PipeWriter {
|
||||
reader, writer := io.Pipe()
|
||||
|
||||
go logger.writerScanner(reader)
|
||||
runtime.SetFinalizer(writer, writerFinalizer)
|
||||
|
||||
return writer
|
||||
}
|
||||
|
||||
func (logger *Logger) writerScanner(reader *io.PipeReader) {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
for scanner.Scan() {
|
||||
logger.Print(scanner.Text())
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
logger.Errorf("Error while reading from Writer: %s", err)
|
||||
}
|
||||
reader.Close()
|
||||
}
|
||||
|
||||
func writerFinalizer(writer *io.PipeWriter) {
|
||||
writer.Close()
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
# This is the official list of Gorilla WebSocket authors for copyright
|
||||
# purposes.
|
||||
#
|
||||
# Please keep the list sorted.
|
||||
|
||||
Gary Burd <gary@beagledreams.com>
|
||||
Joachim Bauch <mail@joachim-bauch.de>
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
Copyright (c) 2013 The Gorilla WebSocket 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.
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
# Gorilla WebSocket
|
||||
|
||||
Gorilla WebSocket is a [Go](http://golang.org/) implementation of the
|
||||
[WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol.
|
||||
|
||||
[](https://travis-ci.org/gorilla/websocket)
|
||||
[](https://godoc.org/github.com/gorilla/websocket)
|
||||
|
||||
### Documentation
|
||||
|
||||
* [API Reference](http://godoc.org/github.com/gorilla/websocket)
|
||||
* [Chat example](https://github.com/gorilla/websocket/tree/master/examples/chat)
|
||||
* [Command example](https://github.com/gorilla/websocket/tree/master/examples/command)
|
||||
* [Client and server example](https://github.com/gorilla/websocket/tree/master/examples/echo)
|
||||
* [File watch example](https://github.com/gorilla/websocket/tree/master/examples/filewatch)
|
||||
|
||||
### Status
|
||||
|
||||
The Gorilla WebSocket package provides a complete and tested implementation of
|
||||
the [WebSocket](http://www.rfc-editor.org/rfc/rfc6455.txt) protocol. The
|
||||
package API is stable.
|
||||
|
||||
### Installation
|
||||
|
||||
go get github.com/gorilla/websocket
|
||||
|
||||
### Protocol Compliance
|
||||
|
||||
The Gorilla WebSocket package passes the server tests in the [Autobahn Test
|
||||
Suite](http://autobahn.ws/testsuite) using the application in the [examples/autobahn
|
||||
subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn).
|
||||
|
||||
### Gorilla WebSocket compared with other packages
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><a href="http://godoc.org/github.com/gorilla/websocket">github.com/gorilla</a></th>
|
||||
<th><a href="http://godoc.org/golang.org/x/net/websocket">golang.org/x/net</a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr><td colspan="3"><a href="http://tools.ietf.org/html/rfc6455">RFC 6455</a> Features</td></tr>
|
||||
<tr><td>Passes <a href="http://autobahn.ws/testsuite/">Autobahn Test Suite</a></td><td><a href="https://github.com/gorilla/websocket/tree/master/examples/autobahn">Yes</a></td><td>No</td></tr>
|
||||
<tr><td>Receive <a href="https://tools.ietf.org/html/rfc6455#section-5.4">fragmented</a> message<td>Yes</td><td><a href="https://code.google.com/p/go/issues/detail?id=7632">No</a>, see note 1</td></tr>
|
||||
<tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">close</a> message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=4588">No</a></td></tr>
|
||||
<tr><td>Send <a href="https://tools.ietf.org/html/rfc6455#section-5.5.2">pings</a> and receive <a href="https://tools.ietf.org/html/rfc6455#section-5.5.3">pongs</a></td><td><a href="http://godoc.org/github.com/gorilla/websocket#hdr-Control_Messages">Yes</a></td><td>No</td></tr>
|
||||
<tr><td>Get the <a href="https://tools.ietf.org/html/rfc6455#section-5.6">type</a> of a received data message</td><td>Yes</td><td>Yes, see note 2</td></tr>
|
||||
<tr><td colspan="3">Other Features</tr></td>
|
||||
<tr><td><a href="https://tools.ietf.org/html/rfc7692">Compression Extensions</a></td><td>Experimental</td><td>No</td></tr>
|
||||
<tr><td>Read message using io.Reader</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextReader">Yes</a></td><td>No, see note 3</td></tr>
|
||||
<tr><td>Write message using io.WriteCloser</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.NextWriter">Yes</a></td><td>No, see note 3</td></tr>
|
||||
</table>
|
||||
|
||||
Notes:
|
||||
|
||||
1. Large messages are fragmented in [Chrome's new WebSocket implementation](http://www.ietf.org/mail-archive/web/hybi/current/msg10503.html).
|
||||
2. The application can get the type of a received data message by implementing
|
||||
a [Codec marshal](http://godoc.org/golang.org/x/net/websocket#Codec.Marshal)
|
||||
function.
|
||||
3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries.
|
||||
Read returns when the input buffer is full or a frame boundary is
|
||||
encountered. Each call to Write sends a single frame message. The Gorilla
|
||||
io.Reader and io.WriteCloser operate on a single WebSocket message.
|
||||
|
||||
-392
@@ -1,392 +0,0 @@
|
||||
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ErrBadHandshake is returned when the server response to opening handshake is
|
||||
// invalid.
|
||||
var ErrBadHandshake = errors.New("websocket: bad handshake")
|
||||
|
||||
var errInvalidCompression = errors.New("websocket: invalid compression negotiation")
|
||||
|
||||
// NewClient creates a new client connection using the given net connection.
|
||||
// The URL u specifies the host and request URI. Use requestHeader to specify
|
||||
// the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies
|
||||
// (Cookie). Use the response.Header to get the selected subprotocol
|
||||
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
|
||||
//
|
||||
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
|
||||
// non-nil *http.Response so that callers can handle redirects, authentication,
|
||||
// etc.
|
||||
//
|
||||
// Deprecated: Use Dialer instead.
|
||||
func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) {
|
||||
d := Dialer{
|
||||
ReadBufferSize: readBufSize,
|
||||
WriteBufferSize: writeBufSize,
|
||||
NetDial: func(net, addr string) (net.Conn, error) {
|
||||
return netConn, nil
|
||||
},
|
||||
}
|
||||
return d.Dial(u.String(), requestHeader)
|
||||
}
|
||||
|
||||
// A Dialer contains options for connecting to WebSocket server.
|
||||
type Dialer struct {
|
||||
// NetDial specifies the dial function for creating TCP connections. If
|
||||
// NetDial is nil, net.Dial is used.
|
||||
NetDial func(network, addr string) (net.Conn, error)
|
||||
|
||||
// Proxy specifies a function to return a proxy for a given
|
||||
// Request. If the function returns a non-nil error, the
|
||||
// request is aborted with the provided error.
|
||||
// If Proxy is nil or returns a nil *URL, no proxy is used.
|
||||
Proxy func(*http.Request) (*url.URL, error)
|
||||
|
||||
// TLSClientConfig specifies the TLS configuration to use with tls.Client.
|
||||
// If nil, the default configuration is used.
|
||||
TLSClientConfig *tls.Config
|
||||
|
||||
// HandshakeTimeout specifies the duration for the handshake to complete.
|
||||
HandshakeTimeout time.Duration
|
||||
|
||||
// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
|
||||
// size is zero, then a useful default size is used. The I/O buffer sizes
|
||||
// do not limit the size of the messages that can be sent or received.
|
||||
ReadBufferSize, WriteBufferSize int
|
||||
|
||||
// Subprotocols specifies the client's requested subprotocols.
|
||||
Subprotocols []string
|
||||
|
||||
// EnableCompression specifies if the client should attempt to negotiate
|
||||
// per message compression (RFC 7692). Setting this value to true does not
|
||||
// guarantee that compression will be supported. Currently only "no context
|
||||
// takeover" modes are supported.
|
||||
EnableCompression bool
|
||||
|
||||
// Jar specifies the cookie jar.
|
||||
// If Jar is nil, cookies are not sent in requests and ignored
|
||||
// in responses.
|
||||
Jar http.CookieJar
|
||||
}
|
||||
|
||||
var errMalformedURL = errors.New("malformed ws or wss URL")
|
||||
|
||||
// parseURL parses the URL.
|
||||
//
|
||||
// This function is a replacement for the standard library url.Parse function.
|
||||
// In Go 1.4 and earlier, url.Parse loses information from the path.
|
||||
func parseURL(s string) (*url.URL, error) {
|
||||
// From the RFC:
|
||||
//
|
||||
// ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
|
||||
// wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]
|
||||
var u url.URL
|
||||
switch {
|
||||
case strings.HasPrefix(s, "ws://"):
|
||||
u.Scheme = "ws"
|
||||
s = s[len("ws://"):]
|
||||
case strings.HasPrefix(s, "wss://"):
|
||||
u.Scheme = "wss"
|
||||
s = s[len("wss://"):]
|
||||
default:
|
||||
return nil, errMalformedURL
|
||||
}
|
||||
|
||||
if i := strings.Index(s, "?"); i >= 0 {
|
||||
u.RawQuery = s[i+1:]
|
||||
s = s[:i]
|
||||
}
|
||||
|
||||
if i := strings.Index(s, "/"); i >= 0 {
|
||||
u.Opaque = s[i:]
|
||||
s = s[:i]
|
||||
} else {
|
||||
u.Opaque = "/"
|
||||
}
|
||||
|
||||
u.Host = s
|
||||
|
||||
if strings.Contains(u.Host, "@") {
|
||||
// Don't bother parsing user information because user information is
|
||||
// not allowed in websocket URIs.
|
||||
return nil, errMalformedURL
|
||||
}
|
||||
|
||||
return &u, nil
|
||||
}
|
||||
|
||||
func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
|
||||
hostPort = u.Host
|
||||
hostNoPort = u.Host
|
||||
if i := strings.LastIndex(u.Host, ":"); i > strings.LastIndex(u.Host, "]") {
|
||||
hostNoPort = hostNoPort[:i]
|
||||
} else {
|
||||
switch u.Scheme {
|
||||
case "wss":
|
||||
hostPort += ":443"
|
||||
case "https":
|
||||
hostPort += ":443"
|
||||
default:
|
||||
hostPort += ":80"
|
||||
}
|
||||
}
|
||||
return hostPort, hostNoPort
|
||||
}
|
||||
|
||||
// DefaultDialer is a dialer with all fields set to the default zero values.
|
||||
var DefaultDialer = &Dialer{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}
|
||||
|
||||
// Dial creates a new client connection. Use requestHeader to specify the
|
||||
// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).
|
||||
// Use the response.Header to get the selected subprotocol
|
||||
// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
|
||||
//
|
||||
// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
|
||||
// non-nil *http.Response so that callers can handle redirects, authentication,
|
||||
// etcetera. The response body may not contain the entire response and does not
|
||||
// need to be closed by the application.
|
||||
func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
|
||||
|
||||
if d == nil {
|
||||
d = &Dialer{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}
|
||||
}
|
||||
|
||||
challengeKey, err := generateChallengeKey()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
u, err := parseURL(urlStr)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
switch u.Scheme {
|
||||
case "ws":
|
||||
u.Scheme = "http"
|
||||
case "wss":
|
||||
u.Scheme = "https"
|
||||
default:
|
||||
return nil, nil, errMalformedURL
|
||||
}
|
||||
|
||||
if u.User != nil {
|
||||
// User name and password are not allowed in websocket URIs.
|
||||
return nil, nil, errMalformedURL
|
||||
}
|
||||
|
||||
req := &http.Request{
|
||||
Method: "GET",
|
||||
URL: u,
|
||||
Proto: "HTTP/1.1",
|
||||
ProtoMajor: 1,
|
||||
ProtoMinor: 1,
|
||||
Header: make(http.Header),
|
||||
Host: u.Host,
|
||||
}
|
||||
|
||||
// Set the cookies present in the cookie jar of the dialer
|
||||
if d.Jar != nil {
|
||||
for _, cookie := range d.Jar.Cookies(u) {
|
||||
req.AddCookie(cookie)
|
||||
}
|
||||
}
|
||||
|
||||
// Set the request headers using the capitalization for names and values in
|
||||
// RFC examples. Although the capitalization shouldn't matter, there are
|
||||
// servers that depend on it. The Header.Set method is not used because the
|
||||
// method canonicalizes the header names.
|
||||
req.Header["Upgrade"] = []string{"websocket"}
|
||||
req.Header["Connection"] = []string{"Upgrade"}
|
||||
req.Header["Sec-WebSocket-Key"] = []string{challengeKey}
|
||||
req.Header["Sec-WebSocket-Version"] = []string{"13"}
|
||||
if len(d.Subprotocols) > 0 {
|
||||
req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")}
|
||||
}
|
||||
for k, vs := range requestHeader {
|
||||
switch {
|
||||
case k == "Host":
|
||||
if len(vs) > 0 {
|
||||
req.Host = vs[0]
|
||||
}
|
||||
case k == "Upgrade" ||
|
||||
k == "Connection" ||
|
||||
k == "Sec-Websocket-Key" ||
|
||||
k == "Sec-Websocket-Version" ||
|
||||
k == "Sec-Websocket-Extensions" ||
|
||||
(k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
|
||||
return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
|
||||
default:
|
||||
req.Header[k] = vs
|
||||
}
|
||||
}
|
||||
|
||||
if d.EnableCompression {
|
||||
req.Header.Set("Sec-Websocket-Extensions", "permessage-deflate; server_no_context_takeover; client_no_context_takeover")
|
||||
}
|
||||
|
||||
hostPort, hostNoPort := hostPortNoPort(u)
|
||||
|
||||
var proxyURL *url.URL
|
||||
// Check wether the proxy method has been configured
|
||||
if d.Proxy != nil {
|
||||
proxyURL, err = d.Proxy(req)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var targetHostPort string
|
||||
if proxyURL != nil {
|
||||
targetHostPort, _ = hostPortNoPort(proxyURL)
|
||||
} else {
|
||||
targetHostPort = hostPort
|
||||
}
|
||||
|
||||
var deadline time.Time
|
||||
if d.HandshakeTimeout != 0 {
|
||||
deadline = time.Now().Add(d.HandshakeTimeout)
|
||||
}
|
||||
|
||||
netDial := d.NetDial
|
||||
if netDial == nil {
|
||||
netDialer := &net.Dialer{Deadline: deadline}
|
||||
netDial = netDialer.Dial
|
||||
}
|
||||
|
||||
netConn, err := netDial("tcp", targetHostPort)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if netConn != nil {
|
||||
netConn.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := netConn.SetDeadline(deadline); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if proxyURL != nil {
|
||||
connectHeader := make(http.Header)
|
||||
if user := proxyURL.User; user != nil {
|
||||
proxyUser := user.Username()
|
||||
if proxyPassword, passwordSet := user.Password(); passwordSet {
|
||||
credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
|
||||
connectHeader.Set("Proxy-Authorization", "Basic "+credential)
|
||||
}
|
||||
}
|
||||
connectReq := &http.Request{
|
||||
Method: "CONNECT",
|
||||
URL: &url.URL{Opaque: hostPort},
|
||||
Host: hostPort,
|
||||
Header: connectHeader,
|
||||
}
|
||||
|
||||
connectReq.Write(netConn)
|
||||
|
||||
// Read response.
|
||||
// Okay to use and discard buffered reader here, because
|
||||
// TLS server will not speak until spoken to.
|
||||
br := bufio.NewReader(netConn)
|
||||
resp, err := http.ReadResponse(br, connectReq)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
f := strings.SplitN(resp.Status, " ", 2)
|
||||
return nil, nil, errors.New(f[1])
|
||||
}
|
||||
}
|
||||
|
||||
if u.Scheme == "https" {
|
||||
cfg := cloneTLSConfig(d.TLSClientConfig)
|
||||
if cfg.ServerName == "" {
|
||||
cfg.ServerName = hostNoPort
|
||||
}
|
||||
tlsConn := tls.Client(netConn, cfg)
|
||||
netConn = tlsConn
|
||||
if err := tlsConn.Handshake(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if !cfg.InsecureSkipVerify {
|
||||
if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize)
|
||||
|
||||
if err := req.Write(netConn); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
resp, err := http.ReadResponse(conn.br, req)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if d.Jar != nil {
|
||||
if rc := resp.Cookies(); len(rc) > 0 {
|
||||
d.Jar.SetCookies(u, rc)
|
||||
}
|
||||
}
|
||||
|
||||
if resp.StatusCode != 101 ||
|
||||
!strings.EqualFold(resp.Header.Get("Upgrade"), "websocket") ||
|
||||
!strings.EqualFold(resp.Header.Get("Connection"), "upgrade") ||
|
||||
resp.Header.Get("Sec-Websocket-Accept") != computeAcceptKey(challengeKey) {
|
||||
// Before closing the network connection on return from this
|
||||
// function, slurp up some of the response to aid application
|
||||
// debugging.
|
||||
buf := make([]byte, 1024)
|
||||
n, _ := io.ReadFull(resp.Body, buf)
|
||||
resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n]))
|
||||
return nil, resp, ErrBadHandshake
|
||||
}
|
||||
|
||||
for _, ext := range parseExtensions(resp.Header) {
|
||||
if ext[""] != "permessage-deflate" {
|
||||
continue
|
||||
}
|
||||
_, snct := ext["server_no_context_takeover"]
|
||||
_, cnct := ext["client_no_context_takeover"]
|
||||
if !snct || !cnct {
|
||||
return nil, resp, errInvalidCompression
|
||||
}
|
||||
conn.newCompressionWriter = compressNoContextTakeover
|
||||
conn.newDecompressionReader = decompressNoContextTakeover
|
||||
break
|
||||
}
|
||||
|
||||
resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
|
||||
conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol")
|
||||
|
||||
netConn.SetDeadline(time.Time{})
|
||||
netConn = nil // to avoid close in defer.
|
||||
return conn, resp, nil
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.8
|
||||
|
||||
package websocket
|
||||
|
||||
import "crypto/tls"
|
||||
|
||||
func cloneTLSConfig(cfg *tls.Config) *tls.Config {
|
||||
if cfg == nil {
|
||||
return &tls.Config{}
|
||||
}
|
||||
return cfg.Clone()
|
||||
}
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !go1.8
|
||||
|
||||
package websocket
|
||||
|
||||
import "crypto/tls"
|
||||
|
||||
// cloneTLSConfig clones all public fields except the fields
|
||||
// SessionTicketsDisabled and SessionTicketKey. This avoids copying the
|
||||
// sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
|
||||
// config in active use.
|
||||
func cloneTLSConfig(cfg *tls.Config) *tls.Config {
|
||||
if cfg == nil {
|
||||
return &tls.Config{}
|
||||
}
|
||||
return &tls.Config{
|
||||
Rand: cfg.Rand,
|
||||
Time: cfg.Time,
|
||||
Certificates: cfg.Certificates,
|
||||
NameToCertificate: cfg.NameToCertificate,
|
||||
GetCertificate: cfg.GetCertificate,
|
||||
RootCAs: cfg.RootCAs,
|
||||
NextProtos: cfg.NextProtos,
|
||||
ServerName: cfg.ServerName,
|
||||
ClientAuth: cfg.ClientAuth,
|
||||
ClientCAs: cfg.ClientCAs,
|
||||
InsecureSkipVerify: cfg.InsecureSkipVerify,
|
||||
CipherSuites: cfg.CipherSuites,
|
||||
PreferServerCipherSuites: cfg.PreferServerCipherSuites,
|
||||
ClientSessionCache: cfg.ClientSessionCache,
|
||||
MinVersion: cfg.MinVersion,
|
||||
MaxVersion: cfg.MaxVersion,
|
||||
CurvePreferences: cfg.CurvePreferences,
|
||||
}
|
||||
}
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
// Copyright 2017 The Gorilla WebSocket 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 websocket
|
||||
|
||||
import (
|
||||
"compress/flate"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
minCompressionLevel = -2 // flate.HuffmanOnly not defined in Go < 1.6
|
||||
maxCompressionLevel = flate.BestCompression
|
||||
defaultCompressionLevel = 1
|
||||
)
|
||||
|
||||
var (
|
||||
flateWriterPools [maxCompressionLevel - minCompressionLevel + 1]sync.Pool
|
||||
flateReaderPool = sync.Pool{New: func() interface{} {
|
||||
return flate.NewReader(nil)
|
||||
}}
|
||||
)
|
||||
|
||||
func decompressNoContextTakeover(r io.Reader) io.ReadCloser {
|
||||
const tail =
|
||||
// Add four bytes as specified in RFC
|
||||
"\x00\x00\xff\xff" +
|
||||
// Add final block to squelch unexpected EOF error from flate reader.
|
||||
"\x01\x00\x00\xff\xff"
|
||||
|
||||
fr, _ := flateReaderPool.Get().(io.ReadCloser)
|
||||
fr.(flate.Resetter).Reset(io.MultiReader(r, strings.NewReader(tail)), nil)
|
||||
return &flateReadWrapper{fr}
|
||||
}
|
||||
|
||||
func isValidCompressionLevel(level int) bool {
|
||||
return minCompressionLevel <= level && level <= maxCompressionLevel
|
||||
}
|
||||
|
||||
func compressNoContextTakeover(w io.WriteCloser, level int) io.WriteCloser {
|
||||
p := &flateWriterPools[level-minCompressionLevel]
|
||||
tw := &truncWriter{w: w}
|
||||
fw, _ := p.Get().(*flate.Writer)
|
||||
if fw == nil {
|
||||
fw, _ = flate.NewWriter(tw, level)
|
||||
} else {
|
||||
fw.Reset(tw)
|
||||
}
|
||||
return &flateWriteWrapper{fw: fw, tw: tw, p: p}
|
||||
}
|
||||
|
||||
// truncWriter is an io.Writer that writes all but the last four bytes of the
|
||||
// stream to another io.Writer.
|
||||
type truncWriter struct {
|
||||
w io.WriteCloser
|
||||
n int
|
||||
p [4]byte
|
||||
}
|
||||
|
||||
func (w *truncWriter) Write(p []byte) (int, error) {
|
||||
n := 0
|
||||
|
||||
// fill buffer first for simplicity.
|
||||
if w.n < len(w.p) {
|
||||
n = copy(w.p[w.n:], p)
|
||||
p = p[n:]
|
||||
w.n += n
|
||||
if len(p) == 0 {
|
||||
return n, nil
|
||||
}
|
||||
}
|
||||
|
||||
m := len(p)
|
||||
if m > len(w.p) {
|
||||
m = len(w.p)
|
||||
}
|
||||
|
||||
if nn, err := w.w.Write(w.p[:m]); err != nil {
|
||||
return n + nn, err
|
||||
}
|
||||
|
||||
copy(w.p[:], w.p[m:])
|
||||
copy(w.p[len(w.p)-m:], p[len(p)-m:])
|
||||
nn, err := w.w.Write(p[:len(p)-m])
|
||||
return n + nn, err
|
||||
}
|
||||
|
||||
type flateWriteWrapper struct {
|
||||
fw *flate.Writer
|
||||
tw *truncWriter
|
||||
p *sync.Pool
|
||||
}
|
||||
|
||||
func (w *flateWriteWrapper) Write(p []byte) (int, error) {
|
||||
if w.fw == nil {
|
||||
return 0, errWriteClosed
|
||||
}
|
||||
return w.fw.Write(p)
|
||||
}
|
||||
|
||||
func (w *flateWriteWrapper) Close() error {
|
||||
if w.fw == nil {
|
||||
return errWriteClosed
|
||||
}
|
||||
err1 := w.fw.Flush()
|
||||
w.p.Put(w.fw)
|
||||
w.fw = nil
|
||||
if w.tw.p != [4]byte{0, 0, 0xff, 0xff} {
|
||||
return errors.New("websocket: internal error, unexpected bytes at end of flate stream")
|
||||
}
|
||||
err2 := w.tw.w.Close()
|
||||
if err1 != nil {
|
||||
return err1
|
||||
}
|
||||
return err2
|
||||
}
|
||||
|
||||
type flateReadWrapper struct {
|
||||
fr io.ReadCloser
|
||||
}
|
||||
|
||||
func (r *flateReadWrapper) Read(p []byte) (int, error) {
|
||||
if r.fr == nil {
|
||||
return 0, io.ErrClosedPipe
|
||||
}
|
||||
n, err := r.fr.Read(p)
|
||||
if err == io.EOF {
|
||||
// Preemptively place the reader back in the pool. This helps with
|
||||
// scenarios where the application does not call NextReader() soon after
|
||||
// this final read.
|
||||
r.Close()
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (r *flateReadWrapper) Close() error {
|
||||
if r.fr == nil {
|
||||
return io.ErrClosedPipe
|
||||
}
|
||||
err := r.fr.Close()
|
||||
flateReaderPool.Put(r.fr)
|
||||
r.fr = nil
|
||||
return err
|
||||
}
|
||||
-1149
File diff suppressed because it is too large
Load Diff
-18
@@ -1,18 +0,0 @@
|
||||
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build go1.5
|
||||
|
||||
package websocket
|
||||
|
||||
import "io"
|
||||
|
||||
func (c *Conn) read(n int) ([]byte, error) {
|
||||
p, err := c.br.Peek(n)
|
||||
if err == io.EOF {
|
||||
err = errUnexpectedEOF
|
||||
}
|
||||
c.br.Discard(len(p))
|
||||
return p, err
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !go1.5
|
||||
|
||||
package websocket
|
||||
|
||||
import "io"
|
||||
|
||||
func (c *Conn) read(n int) ([]byte, error) {
|
||||
p, err := c.br.Peek(n)
|
||||
if err == io.EOF {
|
||||
err = errUnexpectedEOF
|
||||
}
|
||||
if len(p) > 0 {
|
||||
// advance over the bytes just read
|
||||
io.ReadFull(c.br, p)
|
||||
}
|
||||
return p, err
|
||||
}
|
||||
-179
@@ -1,179 +0,0 @@
|
||||
// Copyright 2013 The Gorilla WebSocket 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 websocket implements the WebSocket protocol defined in RFC 6455.
|
||||
//
|
||||
// Overview
|
||||
//
|
||||
// The Conn type represents a WebSocket connection. A server application calls
|
||||
// the Upgrader.Upgrade method from an HTTP request handler to get a *Conn:
|
||||
//
|
||||
// var upgrader = websocket.Upgrader{
|
||||
// ReadBufferSize: 1024,
|
||||
// WriteBufferSize: 1024,
|
||||
// }
|
||||
//
|
||||
// func handler(w http.ResponseWriter, r *http.Request) {
|
||||
// conn, err := upgrader.Upgrade(w, r, nil)
|
||||
// if err != nil {
|
||||
// log.Println(err)
|
||||
// return
|
||||
// }
|
||||
// ... Use conn to send and receive messages.
|
||||
// }
|
||||
//
|
||||
// Call the connection's WriteMessage and ReadMessage methods to send and
|
||||
// receive messages as a slice of bytes. This snippet of code shows how to echo
|
||||
// messages using these methods:
|
||||
//
|
||||
// for {
|
||||
// messageType, p, err := conn.ReadMessage()
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// if err := conn.WriteMessage(messageType, p); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// In above snippet of code, p is a []byte and messageType is an int with value
|
||||
// websocket.BinaryMessage or websocket.TextMessage.
|
||||
//
|
||||
// An application can also send and receive messages using the io.WriteCloser
|
||||
// and io.Reader interfaces. To send a message, call the connection NextWriter
|
||||
// method to get an io.WriteCloser, write the message to the writer and close
|
||||
// the writer when done. To receive a message, call the connection NextReader
|
||||
// method to get an io.Reader and read until io.EOF is returned. This snippet
|
||||
// shows how to echo messages using the NextWriter and NextReader methods:
|
||||
//
|
||||
// for {
|
||||
// messageType, r, err := conn.NextReader()
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// w, err := conn.NextWriter(messageType)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// if _, err := io.Copy(w, r); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// if err := w.Close(); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Data Messages
|
||||
//
|
||||
// The WebSocket protocol distinguishes between text and binary data messages.
|
||||
// Text messages are interpreted as UTF-8 encoded text. The interpretation of
|
||||
// binary messages is left to the application.
|
||||
//
|
||||
// This package uses the TextMessage and BinaryMessage integer constants to
|
||||
// identify the two data message types. The ReadMessage and NextReader methods
|
||||
// return the type of the received message. The messageType argument to the
|
||||
// WriteMessage and NextWriter methods specifies the type of a sent message.
|
||||
//
|
||||
// It is the application's responsibility to ensure that text messages are
|
||||
// valid UTF-8 encoded text.
|
||||
//
|
||||
// Control Messages
|
||||
//
|
||||
// The WebSocket protocol defines three types of control messages: close, ping
|
||||
// and pong. Call the connection WriteControl, WriteMessage or NextWriter
|
||||
// methods to send a control message to the peer.
|
||||
//
|
||||
// Connections handle received close messages by sending a close message to the
|
||||
// peer and returning a *CloseError from the the NextReader, ReadMessage or the
|
||||
// message Read method.
|
||||
//
|
||||
// Connections handle received ping and pong messages by invoking callback
|
||||
// functions set with SetPingHandler and SetPongHandler methods. The callback
|
||||
// functions are called from the NextReader, ReadMessage and the message Read
|
||||
// methods.
|
||||
//
|
||||
// The default ping handler sends a pong to the peer. The application's reading
|
||||
// goroutine can block for a short time while the handler writes the pong data
|
||||
// to the connection.
|
||||
//
|
||||
// The application must read the connection to process ping, pong and close
|
||||
// messages sent from the peer. If the application is not otherwise interested
|
||||
// in messages from the peer, then the application should start a goroutine to
|
||||
// read and discard messages from the peer. A simple example is:
|
||||
//
|
||||
// func readLoop(c *websocket.Conn) {
|
||||
// for {
|
||||
// if _, _, err := c.NextReader(); err != nil {
|
||||
// c.Close()
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Concurrency
|
||||
//
|
||||
// Connections support one concurrent reader and one concurrent writer.
|
||||
//
|
||||
// Applications are responsible for ensuring that no more than one goroutine
|
||||
// calls the write methods (NextWriter, SetWriteDeadline, WriteMessage,
|
||||
// WriteJSON, EnableWriteCompression, SetCompressionLevel) concurrently and
|
||||
// that no more than one goroutine calls the read methods (NextReader,
|
||||
// SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler)
|
||||
// concurrently.
|
||||
//
|
||||
// The Close and WriteControl methods can be called concurrently with all other
|
||||
// methods.
|
||||
//
|
||||
// Origin Considerations
|
||||
//
|
||||
// Web browsers allow Javascript applications to open a WebSocket connection to
|
||||
// any host. It's up to the server to enforce an origin policy using the Origin
|
||||
// request header sent by the browser.
|
||||
//
|
||||
// The Upgrader calls the function specified in the CheckOrigin field to check
|
||||
// the origin. If the CheckOrigin function returns false, then the Upgrade
|
||||
// method fails the WebSocket handshake with HTTP status 403.
|
||||
//
|
||||
// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail
|
||||
// the handshake if the Origin request header is present and not equal to the
|
||||
// Host request header.
|
||||
//
|
||||
// An application can allow connections from any origin by specifying a
|
||||
// function that always returns true:
|
||||
//
|
||||
// var upgrader = websocket.Upgrader{
|
||||
// CheckOrigin: func(r *http.Request) bool { return true },
|
||||
// }
|
||||
//
|
||||
// The deprecated package-level Upgrade function does not perform origin
|
||||
// checking. The application is responsible for checking the Origin header
|
||||
// before calling the Upgrade function.
|
||||
//
|
||||
// Compression EXPERIMENTAL
|
||||
//
|
||||
// Per message compression extensions (RFC 7692) are experimentally supported
|
||||
// by this package in a limited capacity. Setting the EnableCompression option
|
||||
// to true in Dialer or Upgrader will attempt to negotiate per message deflate
|
||||
// support.
|
||||
//
|
||||
// var upgrader = websocket.Upgrader{
|
||||
// EnableCompression: true,
|
||||
// }
|
||||
//
|
||||
// If compression was successfully negotiated with the connection's peer, any
|
||||
// message received in compressed form will be automatically decompressed.
|
||||
// All Read methods will return uncompressed bytes.
|
||||
//
|
||||
// Per message compression of messages written to a connection can be enabled
|
||||
// or disabled by calling the corresponding Conn method:
|
||||
//
|
||||
// conn.EnableWriteCompression(false)
|
||||
//
|
||||
// Currently this package does not support compression with "context takeover".
|
||||
// This means that messages must be compressed and decompressed in isolation,
|
||||
// without retaining sliding window or dictionary state across messages. For
|
||||
// more details refer to RFC 7692.
|
||||
//
|
||||
// Use of compression is experimental and may result in decreased performance.
|
||||
package websocket
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteJSON writes the JSON encoding of v as a message.
|
||||
//
|
||||
// Deprecated: Use c.WriteJSON instead.
|
||||
func WriteJSON(c *Conn, v interface{}) error {
|
||||
return c.WriteJSON(v)
|
||||
}
|
||||
|
||||
// WriteJSON writes the JSON encoding of v as a message.
|
||||
//
|
||||
// See the documentation for encoding/json Marshal for details about the
|
||||
// conversion of Go values to JSON.
|
||||
func (c *Conn) WriteJSON(v interface{}) error {
|
||||
w, err := c.NextWriter(TextMessage)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err1 := json.NewEncoder(w).Encode(v)
|
||||
err2 := w.Close()
|
||||
if err1 != nil {
|
||||
return err1
|
||||
}
|
||||
return err2
|
||||
}
|
||||
|
||||
// ReadJSON reads the next JSON-encoded message from the connection and stores
|
||||
// it in the value pointed to by v.
|
||||
//
|
||||
// Deprecated: Use c.ReadJSON instead.
|
||||
func ReadJSON(c *Conn, v interface{}) error {
|
||||
return c.ReadJSON(v)
|
||||
}
|
||||
|
||||
// ReadJSON reads the next JSON-encoded message from the connection and stores
|
||||
// it in the value pointed to by v.
|
||||
//
|
||||
// See the documentation for the encoding/json Unmarshal function for details
|
||||
// about the conversion of JSON to a Go value.
|
||||
func (c *Conn) ReadJSON(v interface{}) error {
|
||||
_, r, err := c.NextReader()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = json.NewDecoder(r).Decode(v)
|
||||
if err == io.EOF {
|
||||
// One value is expected in the message.
|
||||
err = io.ErrUnexpectedEOF
|
||||
}
|
||||
return err
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in the
|
||||
// LICENSE file.
|
||||
|
||||
// +build !appengine
|
||||
|
||||
package websocket
|
||||
|
||||
import "unsafe"
|
||||
|
||||
const wordSize = int(unsafe.Sizeof(uintptr(0)))
|
||||
|
||||
func maskBytes(key [4]byte, pos int, b []byte) int {
|
||||
|
||||
// Mask one byte at a time for small buffers.
|
||||
if len(b) < 2*wordSize {
|
||||
for i := range b {
|
||||
b[i] ^= key[pos&3]
|
||||
pos++
|
||||
}
|
||||
return pos & 3
|
||||
}
|
||||
|
||||
// Mask one byte at a time to word boundary.
|
||||
if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 {
|
||||
n = wordSize - n
|
||||
for i := range b[:n] {
|
||||
b[i] ^= key[pos&3]
|
||||
pos++
|
||||
}
|
||||
b = b[n:]
|
||||
}
|
||||
|
||||
// Create aligned word size key.
|
||||
var k [wordSize]byte
|
||||
for i := range k {
|
||||
k[i] = key[(pos+i)&3]
|
||||
}
|
||||
kw := *(*uintptr)(unsafe.Pointer(&k))
|
||||
|
||||
// Mask one word at a time.
|
||||
n := (len(b) / wordSize) * wordSize
|
||||
for i := 0; i < n; i += wordSize {
|
||||
*(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw
|
||||
}
|
||||
|
||||
// Mask one byte at a time for remaining bytes.
|
||||
b = b[n:]
|
||||
for i := range b {
|
||||
b[i] ^= key[pos&3]
|
||||
pos++
|
||||
}
|
||||
|
||||
return pos & 3
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
|
||||
// this source code is governed by a BSD-style license that can be found in the
|
||||
// LICENSE file.
|
||||
|
||||
// +build appengine
|
||||
|
||||
package websocket
|
||||
|
||||
func maskBytes(key [4]byte, pos int, b []byte) int {
|
||||
for i := range b {
|
||||
b[i] ^= key[pos&3]
|
||||
pos++
|
||||
}
|
||||
return pos & 3
|
||||
}
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
// Copyright 2017 The Gorilla WebSocket 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 websocket
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PreparedMessage caches on the wire representations of a message payload.
|
||||
// Use PreparedMessage to efficiently send a message payload to multiple
|
||||
// connections. PreparedMessage is especially useful when compression is used
|
||||
// because the CPU and memory expensive compression operation can be executed
|
||||
// once for a given set of compression options.
|
||||
type PreparedMessage struct {
|
||||
messageType int
|
||||
data []byte
|
||||
err error
|
||||
mu sync.Mutex
|
||||
frames map[prepareKey]*preparedFrame
|
||||
}
|
||||
|
||||
// prepareKey defines a unique set of options to cache prepared frames in PreparedMessage.
|
||||
type prepareKey struct {
|
||||
isServer bool
|
||||
compress bool
|
||||
compressionLevel int
|
||||
}
|
||||
|
||||
// preparedFrame contains data in wire representation.
|
||||
type preparedFrame struct {
|
||||
once sync.Once
|
||||
data []byte
|
||||
}
|
||||
|
||||
// NewPreparedMessage returns an initialized PreparedMessage. You can then send
|
||||
// it to connection using WritePreparedMessage method. Valid wire
|
||||
// representation will be calculated lazily only once for a set of current
|
||||
// connection options.
|
||||
func NewPreparedMessage(messageType int, data []byte) (*PreparedMessage, error) {
|
||||
pm := &PreparedMessage{
|
||||
messageType: messageType,
|
||||
frames: make(map[prepareKey]*preparedFrame),
|
||||
data: data,
|
||||
}
|
||||
|
||||
// Prepare a plain server frame.
|
||||
_, frameData, err := pm.frame(prepareKey{isServer: true, compress: false})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// To protect against caller modifying the data argument, remember the data
|
||||
// copied to the plain server frame.
|
||||
pm.data = frameData[len(frameData)-len(data):]
|
||||
return pm, nil
|
||||
}
|
||||
|
||||
func (pm *PreparedMessage) frame(key prepareKey) (int, []byte, error) {
|
||||
pm.mu.Lock()
|
||||
frame, ok := pm.frames[key]
|
||||
if !ok {
|
||||
frame = &preparedFrame{}
|
||||
pm.frames[key] = frame
|
||||
}
|
||||
pm.mu.Unlock()
|
||||
|
||||
var err error
|
||||
frame.once.Do(func() {
|
||||
// Prepare a frame using a 'fake' connection.
|
||||
// TODO: Refactor code in conn.go to allow more direct construction of
|
||||
// the frame.
|
||||
mu := make(chan bool, 1)
|
||||
mu <- true
|
||||
var nc prepareConn
|
||||
c := &Conn{
|
||||
conn: &nc,
|
||||
mu: mu,
|
||||
isServer: key.isServer,
|
||||
compressionLevel: key.compressionLevel,
|
||||
enableWriteCompression: true,
|
||||
writeBuf: make([]byte, defaultWriteBufferSize+maxFrameHeaderSize),
|
||||
}
|
||||
if key.compress {
|
||||
c.newCompressionWriter = compressNoContextTakeover
|
||||
}
|
||||
err = c.WriteMessage(pm.messageType, pm.data)
|
||||
frame.data = nc.buf.Bytes()
|
||||
})
|
||||
return pm.messageType, frame.data, err
|
||||
}
|
||||
|
||||
type prepareConn struct {
|
||||
buf bytes.Buffer
|
||||
net.Conn
|
||||
}
|
||||
|
||||
func (pc *prepareConn) Write(p []byte) (int, error) { return pc.buf.Write(p) }
|
||||
func (pc *prepareConn) SetWriteDeadline(t time.Time) error { return nil }
|
||||
-292
@@ -1,292 +0,0 @@
|
||||
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// HandshakeError describes an error with the handshake from the peer.
|
||||
type HandshakeError struct {
|
||||
message string
|
||||
}
|
||||
|
||||
func (e HandshakeError) Error() string { return e.message }
|
||||
|
||||
// Upgrader specifies parameters for upgrading an HTTP connection to a
|
||||
// WebSocket connection.
|
||||
type Upgrader struct {
|
||||
// HandshakeTimeout specifies the duration for the handshake to complete.
|
||||
HandshakeTimeout time.Duration
|
||||
|
||||
// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
|
||||
// size is zero, then buffers allocated by the HTTP server are used. The
|
||||
// I/O buffer sizes do not limit the size of the messages that can be sent
|
||||
// or received.
|
||||
ReadBufferSize, WriteBufferSize int
|
||||
|
||||
// Subprotocols specifies the server's supported protocols in order of
|
||||
// preference. If this field is set, then the Upgrade method negotiates a
|
||||
// subprotocol by selecting the first match in this list with a protocol
|
||||
// requested by the client.
|
||||
Subprotocols []string
|
||||
|
||||
// Error specifies the function for generating HTTP error responses. If Error
|
||||
// is nil, then http.Error is used to generate the HTTP response.
|
||||
Error func(w http.ResponseWriter, r *http.Request, status int, reason error)
|
||||
|
||||
// CheckOrigin returns true if the request Origin header is acceptable. If
|
||||
// CheckOrigin is nil, the host in the Origin header must not be set or
|
||||
// must match the host of the request.
|
||||
CheckOrigin func(r *http.Request) bool
|
||||
|
||||
// EnableCompression specify if the server should attempt to negotiate per
|
||||
// message compression (RFC 7692). Setting this value to true does not
|
||||
// guarantee that compression will be supported. Currently only "no context
|
||||
// takeover" modes are supported.
|
||||
EnableCompression bool
|
||||
}
|
||||
|
||||
func (u *Upgrader) returnError(w http.ResponseWriter, r *http.Request, status int, reason string) (*Conn, error) {
|
||||
err := HandshakeError{reason}
|
||||
if u.Error != nil {
|
||||
u.Error(w, r, status, err)
|
||||
} else {
|
||||
w.Header().Set("Sec-Websocket-Version", "13")
|
||||
http.Error(w, http.StatusText(status), status)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// checkSameOrigin returns true if the origin is not set or is equal to the request host.
|
||||
func checkSameOrigin(r *http.Request) bool {
|
||||
origin := r.Header["Origin"]
|
||||
if len(origin) == 0 {
|
||||
return true
|
||||
}
|
||||
u, err := url.Parse(origin[0])
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return u.Host == r.Host
|
||||
}
|
||||
|
||||
func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
|
||||
if u.Subprotocols != nil {
|
||||
clientProtocols := Subprotocols(r)
|
||||
for _, serverProtocol := range u.Subprotocols {
|
||||
for _, clientProtocol := range clientProtocols {
|
||||
if clientProtocol == serverProtocol {
|
||||
return clientProtocol
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if responseHeader != nil {
|
||||
return responseHeader.Get("Sec-Websocket-Protocol")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
|
||||
//
|
||||
// The responseHeader is included in the response to the client's upgrade
|
||||
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
|
||||
// application negotiated subprotocol (Sec-Websocket-Protocol).
|
||||
//
|
||||
// If the upgrade fails, then Upgrade replies to the client with an HTTP error
|
||||
// response.
|
||||
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) {
|
||||
if r.Method != "GET" {
|
||||
return u.returnError(w, r, http.StatusMethodNotAllowed, "websocket: not a websocket handshake: request method is not GET")
|
||||
}
|
||||
|
||||
if _, ok := responseHeader["Sec-Websocket-Extensions"]; ok {
|
||||
return u.returnError(w, r, http.StatusInternalServerError, "websocket: application specific 'Sec-Websocket-Extensions' headers are unsupported")
|
||||
}
|
||||
|
||||
if !tokenListContainsValue(r.Header, "Connection", "upgrade") {
|
||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'upgrade' token not found in 'Connection' header")
|
||||
}
|
||||
|
||||
if !tokenListContainsValue(r.Header, "Upgrade", "websocket") {
|
||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'websocket' token not found in 'Upgrade' header")
|
||||
}
|
||||
|
||||
if !tokenListContainsValue(r.Header, "Sec-Websocket-Version", "13") {
|
||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: unsupported version: 13 not found in 'Sec-Websocket-Version' header")
|
||||
}
|
||||
|
||||
checkOrigin := u.CheckOrigin
|
||||
if checkOrigin == nil {
|
||||
checkOrigin = checkSameOrigin
|
||||
}
|
||||
if !checkOrigin(r) {
|
||||
return u.returnError(w, r, http.StatusForbidden, "websocket: 'Origin' header value not allowed")
|
||||
}
|
||||
|
||||
challengeKey := r.Header.Get("Sec-Websocket-Key")
|
||||
if challengeKey == "" {
|
||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: `Sec-Websocket-Key' header is missing or blank")
|
||||
}
|
||||
|
||||
subprotocol := u.selectSubprotocol(r, responseHeader)
|
||||
|
||||
// Negotiate PMCE
|
||||
var compress bool
|
||||
if u.EnableCompression {
|
||||
for _, ext := range parseExtensions(r.Header) {
|
||||
if ext[""] != "permessage-deflate" {
|
||||
continue
|
||||
}
|
||||
compress = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
netConn net.Conn
|
||||
err error
|
||||
)
|
||||
|
||||
h, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
|
||||
}
|
||||
var brw *bufio.ReadWriter
|
||||
netConn, brw, err = h.Hijack()
|
||||
if err != nil {
|
||||
return u.returnError(w, r, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
if brw.Reader.Buffered() > 0 {
|
||||
netConn.Close()
|
||||
return nil, errors.New("websocket: client sent data before handshake is complete")
|
||||
}
|
||||
|
||||
c := newConnBRW(netConn, true, u.ReadBufferSize, u.WriteBufferSize, brw)
|
||||
c.subprotocol = subprotocol
|
||||
|
||||
if compress {
|
||||
c.newCompressionWriter = compressNoContextTakeover
|
||||
c.newDecompressionReader = decompressNoContextTakeover
|
||||
}
|
||||
|
||||
p := c.writeBuf[:0]
|
||||
p = append(p, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "...)
|
||||
p = append(p, computeAcceptKey(challengeKey)...)
|
||||
p = append(p, "\r\n"...)
|
||||
if c.subprotocol != "" {
|
||||
p = append(p, "Sec-Websocket-Protocol: "...)
|
||||
p = append(p, c.subprotocol...)
|
||||
p = append(p, "\r\n"...)
|
||||
}
|
||||
if compress {
|
||||
p = append(p, "Sec-Websocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover\r\n"...)
|
||||
}
|
||||
for k, vs := range responseHeader {
|
||||
if k == "Sec-Websocket-Protocol" {
|
||||
continue
|
||||
}
|
||||
for _, v := range vs {
|
||||
p = append(p, k...)
|
||||
p = append(p, ": "...)
|
||||
for i := 0; i < len(v); i++ {
|
||||
b := v[i]
|
||||
if b <= 31 {
|
||||
// prevent response splitting.
|
||||
b = ' '
|
||||
}
|
||||
p = append(p, b)
|
||||
}
|
||||
p = append(p, "\r\n"...)
|
||||
}
|
||||
}
|
||||
p = append(p, "\r\n"...)
|
||||
|
||||
// Clear deadlines set by HTTP server.
|
||||
netConn.SetDeadline(time.Time{})
|
||||
|
||||
if u.HandshakeTimeout > 0 {
|
||||
netConn.SetWriteDeadline(time.Now().Add(u.HandshakeTimeout))
|
||||
}
|
||||
if _, err = netConn.Write(p); err != nil {
|
||||
netConn.Close()
|
||||
return nil, err
|
||||
}
|
||||
if u.HandshakeTimeout > 0 {
|
||||
netConn.SetWriteDeadline(time.Time{})
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
|
||||
//
|
||||
// Deprecated: Use websocket.Upgrader instead.
|
||||
//
|
||||
// Upgrade does not perform origin checking. The application is responsible for
|
||||
// checking the Origin header before calling Upgrade. An example implementation
|
||||
// of the same origin policy check is:
|
||||
//
|
||||
// if req.Header.Get("Origin") != "http://"+req.Host {
|
||||
// http.Error(w, "Origin not allowed", 403)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// If the endpoint supports subprotocols, then the application is responsible
|
||||
// for negotiating the protocol used on the connection. Use the Subprotocols()
|
||||
// function to get the subprotocols requested by the client. Use the
|
||||
// Sec-Websocket-Protocol response header to specify the subprotocol selected
|
||||
// by the application.
|
||||
//
|
||||
// The responseHeader is included in the response to the client's upgrade
|
||||
// request. Use the responseHeader to specify cookies (Set-Cookie) and the
|
||||
// negotiated subprotocol (Sec-Websocket-Protocol).
|
||||
//
|
||||
// The connection buffers IO to the underlying network connection. The
|
||||
// readBufSize and writeBufSize parameters specify the size of the buffers to
|
||||
// use. Messages can be larger than the buffers.
|
||||
//
|
||||
// If the request is not a valid WebSocket handshake, then Upgrade returns an
|
||||
// error of type HandshakeError. Applications should handle this error by
|
||||
// replying to the client with an HTTP error response.
|
||||
func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) {
|
||||
u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize}
|
||||
u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) {
|
||||
// don't return errors to maintain backwards compatibility
|
||||
}
|
||||
u.CheckOrigin = func(r *http.Request) bool {
|
||||
// allow all connections by default
|
||||
return true
|
||||
}
|
||||
return u.Upgrade(w, r, responseHeader)
|
||||
}
|
||||
|
||||
// Subprotocols returns the subprotocols requested by the client in the
|
||||
// Sec-Websocket-Protocol header.
|
||||
func Subprotocols(r *http.Request) []string {
|
||||
h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol"))
|
||||
if h == "" {
|
||||
return nil
|
||||
}
|
||||
protocols := strings.Split(h, ",")
|
||||
for i := range protocols {
|
||||
protocols[i] = strings.TrimSpace(protocols[i])
|
||||
}
|
||||
return protocols
|
||||
}
|
||||
|
||||
// IsWebSocketUpgrade returns true if the client requested upgrade to the
|
||||
// WebSocket protocol.
|
||||
func IsWebSocketUpgrade(r *http.Request) bool {
|
||||
return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
|
||||
tokenListContainsValue(r.Header, "Upgrade", "websocket")
|
||||
}
|
||||
-214
@@ -1,214 +0,0 @@
|
||||
// Copyright 2013 The Gorilla WebSocket 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 websocket
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha1"
|
||||
"encoding/base64"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
|
||||
|
||||
func computeAcceptKey(challengeKey string) string {
|
||||
h := sha1.New()
|
||||
h.Write([]byte(challengeKey))
|
||||
h.Write(keyGUID)
|
||||
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
func generateChallengeKey() (string, error) {
|
||||
p := make([]byte, 16)
|
||||
if _, err := io.ReadFull(rand.Reader, p); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(p), nil
|
||||
}
|
||||
|
||||
// Octet types from RFC 2616.
|
||||
var octetTypes [256]byte
|
||||
|
||||
const (
|
||||
isTokenOctet = 1 << iota
|
||||
isSpaceOctet
|
||||
)
|
||||
|
||||
func init() {
|
||||
// From RFC 2616
|
||||
//
|
||||
// OCTET = <any 8-bit sequence of data>
|
||||
// CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
// CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
|
||||
// CR = <US-ASCII CR, carriage return (13)>
|
||||
// LF = <US-ASCII LF, linefeed (10)>
|
||||
// SP = <US-ASCII SP, space (32)>
|
||||
// HT = <US-ASCII HT, horizontal-tab (9)>
|
||||
// <"> = <US-ASCII double-quote mark (34)>
|
||||
// CRLF = CR LF
|
||||
// LWS = [CRLF] 1*( SP | HT )
|
||||
// TEXT = <any OCTET except CTLs, but including LWS>
|
||||
// separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <">
|
||||
// | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT
|
||||
// token = 1*<any CHAR except CTLs or separators>
|
||||
// qdtext = <any TEXT except <">>
|
||||
|
||||
for c := 0; c < 256; c++ {
|
||||
var t byte
|
||||
isCtl := c <= 31 || c == 127
|
||||
isChar := 0 <= c && c <= 127
|
||||
isSeparator := strings.IndexRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) >= 0
|
||||
if strings.IndexRune(" \t\r\n", rune(c)) >= 0 {
|
||||
t |= isSpaceOctet
|
||||
}
|
||||
if isChar && !isCtl && !isSeparator {
|
||||
t |= isTokenOctet
|
||||
}
|
||||
octetTypes[c] = t
|
||||
}
|
||||
}
|
||||
|
||||
func skipSpace(s string) (rest string) {
|
||||
i := 0
|
||||
for ; i < len(s); i++ {
|
||||
if octetTypes[s[i]]&isSpaceOctet == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return s[i:]
|
||||
}
|
||||
|
||||
func nextToken(s string) (token, rest string) {
|
||||
i := 0
|
||||
for ; i < len(s); i++ {
|
||||
if octetTypes[s[i]]&isTokenOctet == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return s[:i], s[i:]
|
||||
}
|
||||
|
||||
func nextTokenOrQuoted(s string) (value string, rest string) {
|
||||
if !strings.HasPrefix(s, "\"") {
|
||||
return nextToken(s)
|
||||
}
|
||||
s = s[1:]
|
||||
for i := 0; i < len(s); i++ {
|
||||
switch s[i] {
|
||||
case '"':
|
||||
return s[:i], s[i+1:]
|
||||
case '\\':
|
||||
p := make([]byte, len(s)-1)
|
||||
j := copy(p, s[:i])
|
||||
escape := true
|
||||
for i = i + 1; i < len(s); i++ {
|
||||
b := s[i]
|
||||
switch {
|
||||
case escape:
|
||||
escape = false
|
||||
p[j] = b
|
||||
j++
|
||||
case b == '\\':
|
||||
escape = true
|
||||
case b == '"':
|
||||
return string(p[:j]), s[i+1:]
|
||||
default:
|
||||
p[j] = b
|
||||
j++
|
||||
}
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
|
||||
// tokenListContainsValue returns true if the 1#token header with the given
|
||||
// name contains token.
|
||||
func tokenListContainsValue(header http.Header, name string, value string) bool {
|
||||
headers:
|
||||
for _, s := range header[name] {
|
||||
for {
|
||||
var t string
|
||||
t, s = nextToken(skipSpace(s))
|
||||
if t == "" {
|
||||
continue headers
|
||||
}
|
||||
s = skipSpace(s)
|
||||
if s != "" && s[0] != ',' {
|
||||
continue headers
|
||||
}
|
||||
if strings.EqualFold(t, value) {
|
||||
return true
|
||||
}
|
||||
if s == "" {
|
||||
continue headers
|
||||
}
|
||||
s = s[1:]
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// parseExtensiosn parses WebSocket extensions from a header.
|
||||
func parseExtensions(header http.Header) []map[string]string {
|
||||
|
||||
// From RFC 6455:
|
||||
//
|
||||
// Sec-WebSocket-Extensions = extension-list
|
||||
// extension-list = 1#extension
|
||||
// extension = extension-token *( ";" extension-param )
|
||||
// extension-token = registered-token
|
||||
// registered-token = token
|
||||
// extension-param = token [ "=" (token | quoted-string) ]
|
||||
// ;When using the quoted-string syntax variant, the value
|
||||
// ;after quoted-string unescaping MUST conform to the
|
||||
// ;'token' ABNF.
|
||||
|
||||
var result []map[string]string
|
||||
headers:
|
||||
for _, s := range header["Sec-Websocket-Extensions"] {
|
||||
for {
|
||||
var t string
|
||||
t, s = nextToken(skipSpace(s))
|
||||
if t == "" {
|
||||
continue headers
|
||||
}
|
||||
ext := map[string]string{"": t}
|
||||
for {
|
||||
s = skipSpace(s)
|
||||
if !strings.HasPrefix(s, ";") {
|
||||
break
|
||||
}
|
||||
var k string
|
||||
k, s = nextToken(skipSpace(s[1:]))
|
||||
if k == "" {
|
||||
continue headers
|
||||
}
|
||||
s = skipSpace(s)
|
||||
var v string
|
||||
if strings.HasPrefix(s, "=") {
|
||||
v, s = nextTokenOrQuoted(skipSpace(s[1:]))
|
||||
s = skipSpace(s)
|
||||
}
|
||||
if s != "" && s[0] != ',' && s[0] != ';' {
|
||||
continue headers
|
||||
}
|
||||
ext[k] = v
|
||||
}
|
||||
if s != "" && s[0] != ',' {
|
||||
continue headers
|
||||
}
|
||||
result = append(result, ext)
|
||||
if s == "" {
|
||||
continue headers
|
||||
}
|
||||
s = s[1:]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
Copyright (c) 2015, Dave Cheney <dave@cheney.net>
|
||||
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.
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
# errors [](https://travis-ci.org/pkg/errors) [](https://ci.appveyor.com/project/davecheney/errors/branch/master) [](http://godoc.org/github.com/pkg/errors) [](https://goreportcard.com/report/github.com/pkg/errors)
|
||||
|
||||
Package errors provides simple error handling primitives.
|
||||
|
||||
`go get github.com/pkg/errors`
|
||||
|
||||
The traditional error handling idiom in Go is roughly akin to
|
||||
```go
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
```
|
||||
which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error.
|
||||
|
||||
## Adding context to an error
|
||||
|
||||
The errors.Wrap function returns a new error that adds context to the original error. For example
|
||||
```go
|
||||
_, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "read failed")
|
||||
}
|
||||
```
|
||||
## Retrieving the cause of an error
|
||||
|
||||
Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`.
|
||||
```go
|
||||
type causer interface {
|
||||
Cause() error
|
||||
}
|
||||
```
|
||||
`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example:
|
||||
```go
|
||||
switch err := errors.Cause(err).(type) {
|
||||
case *MyError:
|
||||
// handle specifically
|
||||
default:
|
||||
// unknown error
|
||||
}
|
||||
```
|
||||
|
||||
[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors).
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high.
|
||||
|
||||
Before proposing a change, please discuss your change by raising an issue.
|
||||
|
||||
## Licence
|
||||
|
||||
BSD-2-Clause
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
version: build-{build}.{branch}
|
||||
|
||||
clone_folder: C:\gopath\src\github.com\pkg\errors
|
||||
shallow_clone: true # for startup speed
|
||||
|
||||
environment:
|
||||
GOPATH: C:\gopath
|
||||
|
||||
platform:
|
||||
- x64
|
||||
|
||||
# http://www.appveyor.com/docs/installed-software
|
||||
install:
|
||||
# some helpful output for debugging builds
|
||||
- go version
|
||||
- go env
|
||||
# pre-installed MinGW at C:\MinGW is 32bit only
|
||||
# but MSYS2 at C:\msys64 has mingw64
|
||||
- set PATH=C:\msys64\mingw64\bin;%PATH%
|
||||
- gcc --version
|
||||
- g++ --version
|
||||
|
||||
build_script:
|
||||
- go install -v ./...
|
||||
|
||||
test_script:
|
||||
- set PATH=C:\gopath\bin;%PATH%
|
||||
- go test -v ./...
|
||||
|
||||
#artifacts:
|
||||
# - path: '%GOPATH%\bin\*.exe'
|
||||
deploy: off
|
||||
-269
@@ -1,269 +0,0 @@
|
||||
// Package errors provides simple error handling primitives.
|
||||
//
|
||||
// The traditional error handling idiom in Go is roughly akin to
|
||||
//
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// which applied recursively up the call stack results in error reports
|
||||
// without context or debugging information. The errors package allows
|
||||
// programmers to add context to the failure path in their code in a way
|
||||
// that does not destroy the original value of the error.
|
||||
//
|
||||
// Adding context to an error
|
||||
//
|
||||
// The errors.Wrap function returns a new error that adds context to the
|
||||
// original error by recording a stack trace at the point Wrap is called,
|
||||
// and the supplied message. For example
|
||||
//
|
||||
// _, err := ioutil.ReadAll(r)
|
||||
// if err != nil {
|
||||
// return errors.Wrap(err, "read failed")
|
||||
// }
|
||||
//
|
||||
// If additional control is required the errors.WithStack and errors.WithMessage
|
||||
// functions destructure errors.Wrap into its component operations of annotating
|
||||
// an error with a stack trace and an a message, respectively.
|
||||
//
|
||||
// Retrieving the cause of an error
|
||||
//
|
||||
// Using errors.Wrap constructs a stack of errors, adding context to the
|
||||
// preceding error. Depending on the nature of the error it may be necessary
|
||||
// to reverse the operation of errors.Wrap to retrieve the original error
|
||||
// for inspection. Any error value which implements this interface
|
||||
//
|
||||
// type causer interface {
|
||||
// Cause() error
|
||||
// }
|
||||
//
|
||||
// can be inspected by errors.Cause. errors.Cause will recursively retrieve
|
||||
// the topmost error which does not implement causer, which is assumed to be
|
||||
// the original cause. For example:
|
||||
//
|
||||
// switch err := errors.Cause(err).(type) {
|
||||
// case *MyError:
|
||||
// // handle specifically
|
||||
// default:
|
||||
// // unknown error
|
||||
// }
|
||||
//
|
||||
// causer interface is not exported by this package, but is considered a part
|
||||
// of stable public API.
|
||||
//
|
||||
// Formatted printing of errors
|
||||
//
|
||||
// All error values returned from this package implement fmt.Formatter and can
|
||||
// be formatted by the fmt package. The following verbs are supported
|
||||
//
|
||||
// %s print the error. If the error has a Cause it will be
|
||||
// printed recursively
|
||||
// %v see %s
|
||||
// %+v extended format. Each Frame of the error's StackTrace will
|
||||
// be printed in detail.
|
||||
//
|
||||
// Retrieving the stack trace of an error or wrapper
|
||||
//
|
||||
// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are
|
||||
// invoked. This information can be retrieved with the following interface.
|
||||
//
|
||||
// type stackTracer interface {
|
||||
// StackTrace() errors.StackTrace
|
||||
// }
|
||||
//
|
||||
// Where errors.StackTrace is defined as
|
||||
//
|
||||
// type StackTrace []Frame
|
||||
//
|
||||
// The Frame type represents a call site in the stack trace. Frame supports
|
||||
// the fmt.Formatter interface that can be used for printing information about
|
||||
// the stack trace of this error. For example:
|
||||
//
|
||||
// if err, ok := err.(stackTracer); ok {
|
||||
// for _, f := range err.StackTrace() {
|
||||
// fmt.Printf("%+s:%d", f)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// stackTracer interface is not exported by this package, but is considered a part
|
||||
// of stable public API.
|
||||
//
|
||||
// See the documentation for Frame.Format for more details.
|
||||
package errors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// New returns an error with the supplied message.
|
||||
// New also records the stack trace at the point it was called.
|
||||
func New(message string) error {
|
||||
return &fundamental{
|
||||
msg: message,
|
||||
stack: callers(),
|
||||
}
|
||||
}
|
||||
|
||||
// Errorf formats according to a format specifier and returns the string
|
||||
// as a value that satisfies error.
|
||||
// Errorf also records the stack trace at the point it was called.
|
||||
func Errorf(format string, args ...interface{}) error {
|
||||
return &fundamental{
|
||||
msg: fmt.Sprintf(format, args...),
|
||||
stack: callers(),
|
||||
}
|
||||
}
|
||||
|
||||
// fundamental is an error that has a message and a stack, but no caller.
|
||||
type fundamental struct {
|
||||
msg string
|
||||
*stack
|
||||
}
|
||||
|
||||
func (f *fundamental) Error() string { return f.msg }
|
||||
|
||||
func (f *fundamental) Format(s fmt.State, verb rune) {
|
||||
switch verb {
|
||||
case 'v':
|
||||
if s.Flag('+') {
|
||||
io.WriteString(s, f.msg)
|
||||
f.stack.Format(s, verb)
|
||||
return
|
||||
}
|
||||
fallthrough
|
||||
case 's':
|
||||
io.WriteString(s, f.msg)
|
||||
case 'q':
|
||||
fmt.Fprintf(s, "%q", f.msg)
|
||||
}
|
||||
}
|
||||
|
||||
// WithStack annotates err with a stack trace at the point WithStack was called.
|
||||
// If err is nil, WithStack returns nil.
|
||||
func WithStack(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return &withStack{
|
||||
err,
|
||||
callers(),
|
||||
}
|
||||
}
|
||||
|
||||
type withStack struct {
|
||||
error
|
||||
*stack
|
||||
}
|
||||
|
||||
func (w *withStack) Cause() error { return w.error }
|
||||
|
||||
func (w *withStack) Format(s fmt.State, verb rune) {
|
||||
switch verb {
|
||||
case 'v':
|
||||
if s.Flag('+') {
|
||||
fmt.Fprintf(s, "%+v", w.Cause())
|
||||
w.stack.Format(s, verb)
|
||||
return
|
||||
}
|
||||
fallthrough
|
||||
case 's':
|
||||
io.WriteString(s, w.Error())
|
||||
case 'q':
|
||||
fmt.Fprintf(s, "%q", w.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap returns an error annotating err with a stack trace
|
||||
// at the point Wrap is called, and the supplied message.
|
||||
// If err is nil, Wrap returns nil.
|
||||
func Wrap(err error, message string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
err = &withMessage{
|
||||
cause: err,
|
||||
msg: message,
|
||||
}
|
||||
return &withStack{
|
||||
err,
|
||||
callers(),
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapf returns an error annotating err with a stack trace
|
||||
// at the point Wrapf is call, and the format specifier.
|
||||
// If err is nil, Wrapf returns nil.
|
||||
func Wrapf(err error, format string, args ...interface{}) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
err = &withMessage{
|
||||
cause: err,
|
||||
msg: fmt.Sprintf(format, args...),
|
||||
}
|
||||
return &withStack{
|
||||
err,
|
||||
callers(),
|
||||
}
|
||||
}
|
||||
|
||||
// WithMessage annotates err with a new message.
|
||||
// If err is nil, WithMessage returns nil.
|
||||
func WithMessage(err error, message string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return &withMessage{
|
||||
cause: err,
|
||||
msg: message,
|
||||
}
|
||||
}
|
||||
|
||||
type withMessage struct {
|
||||
cause error
|
||||
msg string
|
||||
}
|
||||
|
||||
func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() }
|
||||
func (w *withMessage) Cause() error { return w.cause }
|
||||
|
||||
func (w *withMessage) Format(s fmt.State, verb rune) {
|
||||
switch verb {
|
||||
case 'v':
|
||||
if s.Flag('+') {
|
||||
fmt.Fprintf(s, "%+v\n", w.Cause())
|
||||
io.WriteString(s, w.msg)
|
||||
return
|
||||
}
|
||||
fallthrough
|
||||
case 's', 'q':
|
||||
io.WriteString(s, w.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// Cause returns the underlying cause of the error, if possible.
|
||||
// An error value has a cause if it implements the following
|
||||
// interface:
|
||||
//
|
||||
// type causer interface {
|
||||
// Cause() error
|
||||
// }
|
||||
//
|
||||
// If the error does not implement Cause, the original error will
|
||||
// be returned. If the error is nil, nil will be returned without further
|
||||
// investigation.
|
||||
func Cause(err error) error {
|
||||
type causer interface {
|
||||
Cause() error
|
||||
}
|
||||
|
||||
for err != nil {
|
||||
cause, ok := err.(causer)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
err = cause.Cause()
|
||||
}
|
||||
return err
|
||||
}
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Frame represents a program counter inside a stack frame.
|
||||
type Frame uintptr
|
||||
|
||||
// pc returns the program counter for this frame;
|
||||
// multiple frames may have the same PC value.
|
||||
func (f Frame) pc() uintptr { return uintptr(f) - 1 }
|
||||
|
||||
// file returns the full path to the file that contains the
|
||||
// function for this Frame's pc.
|
||||
func (f Frame) file() string {
|
||||
fn := runtime.FuncForPC(f.pc())
|
||||
if fn == nil {
|
||||
return "unknown"
|
||||
}
|
||||
file, _ := fn.FileLine(f.pc())
|
||||
return file
|
||||
}
|
||||
|
||||
// line returns the line number of source code of the
|
||||
// function for this Frame's pc.
|
||||
func (f Frame) line() int {
|
||||
fn := runtime.FuncForPC(f.pc())
|
||||
if fn == nil {
|
||||
return 0
|
||||
}
|
||||
_, line := fn.FileLine(f.pc())
|
||||
return line
|
||||
}
|
||||
|
||||
// Format formats the frame according to the fmt.Formatter interface.
|
||||
//
|
||||
// %s source file
|
||||
// %d source line
|
||||
// %n function name
|
||||
// %v equivalent to %s:%d
|
||||
//
|
||||
// Format accepts flags that alter the printing of some verbs, as follows:
|
||||
//
|
||||
// %+s path of source file relative to the compile time GOPATH
|
||||
// %+v equivalent to %+s:%d
|
||||
func (f Frame) Format(s fmt.State, verb rune) {
|
||||
switch verb {
|
||||
case 's':
|
||||
switch {
|
||||
case s.Flag('+'):
|
||||
pc := f.pc()
|
||||
fn := runtime.FuncForPC(pc)
|
||||
if fn == nil {
|
||||
io.WriteString(s, "unknown")
|
||||
} else {
|
||||
file, _ := fn.FileLine(pc)
|
||||
fmt.Fprintf(s, "%s\n\t%s", fn.Name(), file)
|
||||
}
|
||||
default:
|
||||
io.WriteString(s, path.Base(f.file()))
|
||||
}
|
||||
case 'd':
|
||||
fmt.Fprintf(s, "%d", f.line())
|
||||
case 'n':
|
||||
name := runtime.FuncForPC(f.pc()).Name()
|
||||
io.WriteString(s, funcname(name))
|
||||
case 'v':
|
||||
f.Format(s, 's')
|
||||
io.WriteString(s, ":")
|
||||
f.Format(s, 'd')
|
||||
}
|
||||
}
|
||||
|
||||
// StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
|
||||
type StackTrace []Frame
|
||||
|
||||
// Format formats the stack of Frames according to the fmt.Formatter interface.
|
||||
//
|
||||
// %s lists source files for each Frame in the stack
|
||||
// %v lists the source file and line number for each Frame in the stack
|
||||
//
|
||||
// Format accepts flags that alter the printing of some verbs, as follows:
|
||||
//
|
||||
// %+v Prints filename, function, and line number for each Frame in the stack.
|
||||
func (st StackTrace) Format(s fmt.State, verb rune) {
|
||||
switch verb {
|
||||
case 'v':
|
||||
switch {
|
||||
case s.Flag('+'):
|
||||
for _, f := range st {
|
||||
fmt.Fprintf(s, "\n%+v", f)
|
||||
}
|
||||
case s.Flag('#'):
|
||||
fmt.Fprintf(s, "%#v", []Frame(st))
|
||||
default:
|
||||
fmt.Fprintf(s, "%v", []Frame(st))
|
||||
}
|
||||
case 's':
|
||||
fmt.Fprintf(s, "%s", []Frame(st))
|
||||
}
|
||||
}
|
||||
|
||||
// stack represents a stack of program counters.
|
||||
type stack []uintptr
|
||||
|
||||
func (s *stack) Format(st fmt.State, verb rune) {
|
||||
switch verb {
|
||||
case 'v':
|
||||
switch {
|
||||
case st.Flag('+'):
|
||||
for _, pc := range *s {
|
||||
f := Frame(pc)
|
||||
fmt.Fprintf(st, "\n%+v", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *stack) StackTrace() StackTrace {
|
||||
f := make([]Frame, len(*s))
|
||||
for i := 0; i < len(f); i++ {
|
||||
f[i] = Frame((*s)[i])
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func callers() *stack {
|
||||
const depth = 32
|
||||
var pcs [depth]uintptr
|
||||
n := runtime.Callers(3, pcs[:])
|
||||
var st stack = pcs[0:n]
|
||||
return &st
|
||||
}
|
||||
|
||||
// funcname removes the path prefix component of a function's name reported by func.Name().
|
||||
func funcname(name string) string {
|
||||
i := strings.LastIndex(name, "/")
|
||||
name = name[i+1:]
|
||||
i = strings.Index(name, ".")
|
||||
return name[i+1:]
|
||||
}
|
||||
|
||||
func trimGOPATH(name, file string) string {
|
||||
// Here we want to get the source file path relative to the compile time
|
||||
// GOPATH. As of Go 1.6.x there is no direct way to know the compiled
|
||||
// GOPATH at runtime, but we can infer the number of path segments in the
|
||||
// GOPATH. We note that fn.Name() returns the function name qualified by
|
||||
// the import path, which does not include the GOPATH. Thus we can trim
|
||||
// segments from the beginning of the file path until the number of path
|
||||
// separators remaining is one more than the number of path separators in
|
||||
// the function name. For example, given:
|
||||
//
|
||||
// GOPATH /home/user
|
||||
// file /home/user/src/pkg/sub/file.go
|
||||
// fn.Name() pkg/sub.Type.Method
|
||||
//
|
||||
// We want to produce:
|
||||
//
|
||||
// pkg/sub/file.go
|
||||
//
|
||||
// From this we can easily see that fn.Name() has one less path separator
|
||||
// than our desired output. We count separators from the end of the file
|
||||
// path until it finds two more than in the function name and then move
|
||||
// one character forward to preserve the initial path segment without a
|
||||
// leading separator.
|
||||
const sep = "/"
|
||||
goal := strings.Count(name, sep) + 2
|
||||
i := len(file)
|
||||
for n := 0; n < goal; n++ {
|
||||
i = strings.LastIndex(file[:i], sep)
|
||||
if i == -1 {
|
||||
// not enough separators found, set i so that the slice expression
|
||||
// below leaves file unmodified
|
||||
i = -len(sep)
|
||||
break
|
||||
}
|
||||
}
|
||||
// get back to 0 or trim the leading separator
|
||||
file = file[i+len(sep):]
|
||||
return file
|
||||
}
|
||||
-177
@@ -1,177 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
type RancherBaseClientImpl struct {
|
||||
Opts *ClientOpts
|
||||
Schemas *Schemas
|
||||
Types map[string]Schema
|
||||
}
|
||||
|
||||
type RancherBaseClient interface {
|
||||
Websocket(string, map[string][]string) (*websocket.Conn, *http.Response, error)
|
||||
List(string, *ListOpts, interface{}) error
|
||||
Post(string, interface{}, interface{}) error
|
||||
GetLink(Resource, string, interface{}) error
|
||||
Create(string, interface{}, interface{}) error
|
||||
Update(string, *Resource, interface{}, interface{}) error
|
||||
ById(string, string, interface{}) error
|
||||
Delete(*Resource) error
|
||||
Reload(*Resource, interface{}) error
|
||||
Action(string, string, *Resource, interface{}, interface{}) error
|
||||
GetOpts() *ClientOpts
|
||||
GetSchemas() *Schemas
|
||||
GetTypes() map[string]Schema
|
||||
|
||||
doGet(string, *ListOpts, interface{}) error
|
||||
doList(string, *ListOpts, interface{}) error
|
||||
doNext(string, interface{}) error
|
||||
doModify(string, string, interface{}, interface{}) error
|
||||
doCreate(string, interface{}, interface{}) error
|
||||
doUpdate(string, *Resource, interface{}, interface{}) error
|
||||
doById(string, string, interface{}) error
|
||||
doResourceDelete(string, *Resource) error
|
||||
doAction(string, string, *Resource, interface{}, interface{}) error
|
||||
}
|
||||
-620
@@ -1,620 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
SELF = "self"
|
||||
COLLECTION = "collection"
|
||||
)
|
||||
|
||||
var (
|
||||
debug = false
|
||||
dialer = &websocket.Dialer{}
|
||||
privateFieldRegex = regexp.MustCompile("^[[:lower:]]")
|
||||
)
|
||||
|
||||
type ClientOpts struct {
|
||||
Url string
|
||||
AccessKey string
|
||||
SecretKey string
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
type ApiError struct {
|
||||
StatusCode int
|
||||
Url string
|
||||
Msg string
|
||||
Status string
|
||||
Body string
|
||||
}
|
||||
|
||||
func (e *ApiError) Error() string {
|
||||
return e.Msg
|
||||
}
|
||||
|
||||
func IsNotFound(err error) bool {
|
||||
apiError, ok := err.(*ApiError)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
return apiError.StatusCode == http.StatusNotFound
|
||||
}
|
||||
|
||||
func newApiError(resp *http.Response, url string) *ApiError {
|
||||
contents, err := ioutil.ReadAll(resp.Body)
|
||||
var body string
|
||||
if err != nil {
|
||||
body = "Unreadable body."
|
||||
} else {
|
||||
body = string(contents)
|
||||
}
|
||||
|
||||
data := map[string]interface{}{}
|
||||
if json.Unmarshal(contents, &data) == nil {
|
||||
delete(data, "id")
|
||||
delete(data, "links")
|
||||
delete(data, "actions")
|
||||
delete(data, "type")
|
||||
delete(data, "status")
|
||||
buf := &bytes.Buffer{}
|
||||
for k, v := range data {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
if buf.Len() > 0 {
|
||||
buf.WriteString(", ")
|
||||
}
|
||||
fmt.Fprintf(buf, "%s=%v", k, v)
|
||||
}
|
||||
body = buf.String()
|
||||
}
|
||||
formattedMsg := fmt.Sprintf("Bad response statusCode [%d]. Status [%s]. Body: [%s] from [%s]",
|
||||
resp.StatusCode, resp.Status, body, url)
|
||||
return &ApiError{
|
||||
Url: url,
|
||||
Msg: formattedMsg,
|
||||
StatusCode: resp.StatusCode,
|
||||
Status: resp.Status,
|
||||
Body: body,
|
||||
}
|
||||
}
|
||||
|
||||
func contains(array []string, item string) bool {
|
||||
for _, check := range array {
|
||||
if check == item {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func appendFilters(urlString string, filters map[string]interface{}) (string, error) {
|
||||
if len(filters) == 0 {
|
||||
return urlString, nil
|
||||
}
|
||||
|
||||
u, err := url.Parse(urlString)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
q := u.Query()
|
||||
for k, v := range filters {
|
||||
if l, ok := v.([]string); ok {
|
||||
for _, v := range l {
|
||||
q.Add(k, v)
|
||||
}
|
||||
} else {
|
||||
q.Add(k, fmt.Sprintf("%v", v))
|
||||
}
|
||||
}
|
||||
|
||||
u.RawQuery = q.Encode()
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func NormalizeUrl(existingUrl string) (string, error) {
|
||||
u, err := url.Parse(existingUrl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if u.Path == "" || u.Path == "/" {
|
||||
u.Path = "v2-beta"
|
||||
} else if u.Path == "/v1" || strings.HasPrefix(u.Path, "/v1/") {
|
||||
u.Path = strings.Replace(u.Path, "/v1", "/v2-beta", 1)
|
||||
}
|
||||
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func setupRancherBaseClient(rancherClient *RancherBaseClientImpl, opts *ClientOpts) error {
|
||||
var err error
|
||||
opts.Url, err = NormalizeUrl(opts.Url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if opts.Timeout == 0 {
|
||||
opts.Timeout = time.Second * 10
|
||||
}
|
||||
client := &http.Client{Timeout: opts.Timeout}
|
||||
req, err := http.NewRequest("GET", opts.Url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req.SetBasicAuth(opts.AccessKey, opts.SecretKey)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return newApiError(resp, opts.Url)
|
||||
}
|
||||
|
||||
schemasUrls := resp.Header.Get("X-API-Schemas")
|
||||
if len(schemasUrls) == 0 {
|
||||
return errors.New("Failed to find schema at [" + opts.Url + "]")
|
||||
}
|
||||
|
||||
if schemasUrls != opts.Url {
|
||||
req, err = http.NewRequest("GET", schemasUrls, nil)
|
||||
req.SetBasicAuth(opts.AccessKey, opts.SecretKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err = client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return newApiError(resp, opts.Url)
|
||||
}
|
||||
}
|
||||
|
||||
var schemas Schemas
|
||||
bytes, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bytes, &schemas)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rancherClient.Opts = opts
|
||||
rancherClient.Schemas = &schemas
|
||||
|
||||
for _, schema := range schemas.Data {
|
||||
rancherClient.Types[schema.Id] = schema
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewListOpts() *ListOpts {
|
||||
return &ListOpts{
|
||||
Filters: map[string]interface{}{},
|
||||
}
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) setupRequest(req *http.Request) {
|
||||
req.SetBasicAuth(rancherClient.Opts.AccessKey, rancherClient.Opts.SecretKey)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) newHttpClient() *http.Client {
|
||||
if rancherClient.Opts.Timeout == 0 {
|
||||
rancherClient.Opts.Timeout = time.Second * 10
|
||||
}
|
||||
return &http.Client{Timeout: rancherClient.Opts.Timeout}
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doDelete(url string) error {
|
||||
client := rancherClient.newHttpClient()
|
||||
req, err := http.NewRequest("DELETE", url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rancherClient.setupRequest(req)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
|
||||
if resp.StatusCode >= 300 {
|
||||
return newApiError(resp, url)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error) {
|
||||
httpHeaders := http.Header{}
|
||||
for k, v := range httpHeaders {
|
||||
httpHeaders[k] = v
|
||||
}
|
||||
|
||||
if rancherClient.Opts != nil {
|
||||
s := rancherClient.Opts.AccessKey + ":" + rancherClient.Opts.SecretKey
|
||||
httpHeaders.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(s)))
|
||||
}
|
||||
|
||||
return dialer.Dial(url, http.Header(httpHeaders))
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doGet(url string, opts *ListOpts, respObject interface{}) error {
|
||||
if opts == nil {
|
||||
opts = NewListOpts()
|
||||
}
|
||||
url, err := appendFilters(url, opts.Filters)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if debug {
|
||||
fmt.Println("GET " + url)
|
||||
}
|
||||
|
||||
client := rancherClient.newHttpClient()
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rancherClient.setupRequest(req)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return newApiError(resp, url)
|
||||
}
|
||||
|
||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if debug {
|
||||
fmt.Println("Response <= " + string(byteContent))
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(byteContent, respObject); err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse: %s", byteContent))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) List(schemaType string, opts *ListOpts, respObject interface{}) error {
|
||||
return rancherClient.doList(schemaType, opts, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doList(schemaType string, opts *ListOpts, respObject interface{}) error {
|
||||
schema, ok := rancherClient.Types[schemaType]
|
||||
if !ok {
|
||||
return errors.New("Unknown schema type [" + schemaType + "]")
|
||||
}
|
||||
|
||||
if !contains(schema.CollectionMethods, "GET") {
|
||||
return errors.New("Resource type [" + schemaType + "] is not listable")
|
||||
}
|
||||
|
||||
collectionUrl, ok := schema.Links[COLLECTION]
|
||||
if !ok {
|
||||
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||
}
|
||||
|
||||
return rancherClient.doGet(collectionUrl, opts, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doNext(nextUrl string, respObject interface{}) error {
|
||||
return rancherClient.doGet(nextUrl, nil, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) Post(url string, createObj interface{}, respObject interface{}) error {
|
||||
return rancherClient.doModify("POST", url, createObj, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) GetLink(resource Resource, link string, respObject interface{}) error {
|
||||
url := resource.Links[link]
|
||||
if url == "" {
|
||||
return fmt.Errorf("Failed to find link: %s", link)
|
||||
}
|
||||
|
||||
return rancherClient.doGet(url, &ListOpts{}, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doModify(method string, url string, createObj interface{}, respObject interface{}) error {
|
||||
bodyContent, err := json.Marshal(createObj)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if debug {
|
||||
fmt.Println(method + " " + url)
|
||||
fmt.Println("Request => " + string(bodyContent))
|
||||
}
|
||||
|
||||
client := rancherClient.newHttpClient()
|
||||
req, err := http.NewRequest(method, url, bytes.NewBuffer(bodyContent))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rancherClient.setupRequest(req)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 300 {
|
||||
return newApiError(resp, url)
|
||||
}
|
||||
|
||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(byteContent) > 0 {
|
||||
if debug {
|
||||
fmt.Println("Response <= " + string(byteContent))
|
||||
}
|
||||
return json.Unmarshal(byteContent, respObject)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) Create(schemaType string, createObj interface{}, respObject interface{}) error {
|
||||
return rancherClient.doCreate(schemaType, createObj, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doCreate(schemaType string, createObj interface{}, respObject interface{}) error {
|
||||
if createObj == nil {
|
||||
createObj = map[string]string{}
|
||||
}
|
||||
if respObject == nil {
|
||||
respObject = &map[string]interface{}{}
|
||||
}
|
||||
schema, ok := rancherClient.Types[schemaType]
|
||||
if !ok {
|
||||
return errors.New("Unknown schema type [" + schemaType + "]")
|
||||
}
|
||||
|
||||
if !contains(schema.CollectionMethods, "POST") {
|
||||
return errors.New("Resource type [" + schemaType + "] is not creatable")
|
||||
}
|
||||
|
||||
var collectionUrl string
|
||||
collectionUrl, ok = schema.Links[COLLECTION]
|
||||
if !ok {
|
||||
// return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||
// This is a hack to address https://github.com/rancher/cattle/issues/254
|
||||
re := regexp.MustCompile("schemas.*")
|
||||
collectionUrl = re.ReplaceAllString(schema.Links[SELF], schema.PluralName)
|
||||
}
|
||||
|
||||
return rancherClient.doModify("POST", collectionUrl, createObj, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) Update(schemaType string, existing *Resource, updates interface{}, respObject interface{}) error {
|
||||
return rancherClient.doUpdate(schemaType, existing, updates, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doUpdate(schemaType string, existing *Resource, updates interface{}, respObject interface{}) error {
|
||||
if existing == nil {
|
||||
return errors.New("Existing object is nil")
|
||||
}
|
||||
|
||||
selfUrl, ok := existing.Links[SELF]
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
||||
}
|
||||
|
||||
if updates == nil {
|
||||
updates = map[string]string{}
|
||||
}
|
||||
|
||||
if respObject == nil {
|
||||
respObject = &map[string]interface{}{}
|
||||
}
|
||||
|
||||
schema, ok := rancherClient.Types[schemaType]
|
||||
if !ok {
|
||||
return errors.New("Unknown schema type [" + schemaType + "]")
|
||||
}
|
||||
|
||||
if !contains(schema.ResourceMethods, "PUT") {
|
||||
return errors.New("Resource type [" + schemaType + "] is not updatable")
|
||||
}
|
||||
|
||||
return rancherClient.doModify("PUT", selfUrl, updates, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) ById(schemaType string, id string, respObject interface{}) error {
|
||||
return rancherClient.doById(schemaType, id, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doById(schemaType string, id string, respObject interface{}) error {
|
||||
schema, ok := rancherClient.Types[schemaType]
|
||||
if !ok {
|
||||
return errors.New("Unknown schema type [" + schemaType + "]")
|
||||
}
|
||||
|
||||
if !contains(schema.ResourceMethods, "GET") {
|
||||
return errors.New("Resource type [" + schemaType + "] can not be looked up by ID")
|
||||
}
|
||||
|
||||
collectionUrl, ok := schema.Links[COLLECTION]
|
||||
if !ok {
|
||||
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||
}
|
||||
|
||||
err := rancherClient.doGet(collectionUrl+"/"+id, nil, respObject)
|
||||
//TODO check for 404 and return nil, nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) Delete(existing *Resource) error {
|
||||
if existing == nil {
|
||||
return nil
|
||||
}
|
||||
return rancherClient.doResourceDelete(existing.Type, existing)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doResourceDelete(schemaType string, existing *Resource) error {
|
||||
schema, ok := rancherClient.Types[schemaType]
|
||||
if !ok {
|
||||
return errors.New("Unknown schema type [" + schemaType + "]")
|
||||
}
|
||||
|
||||
if !contains(schema.ResourceMethods, "DELETE") {
|
||||
return errors.New("Resource type [" + schemaType + "] can not be deleted")
|
||||
}
|
||||
|
||||
selfUrl, ok := existing.Links[SELF]
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
||||
}
|
||||
|
||||
return rancherClient.doDelete(selfUrl)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) Reload(existing *Resource, output interface{}) error {
|
||||
selfUrl, ok := existing.Links[SELF]
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
||||
}
|
||||
|
||||
return rancherClient.doGet(selfUrl, NewListOpts(), output)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) Action(schemaType string, action string,
|
||||
existing *Resource, inputObject, respObject interface{}) error {
|
||||
return rancherClient.doAction(schemaType, action, existing, inputObject, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) doAction(schemaType string, action string,
|
||||
existing *Resource, inputObject, respObject interface{}) error {
|
||||
|
||||
if existing == nil {
|
||||
return errors.New("Existing object is nil")
|
||||
}
|
||||
|
||||
actionUrl, ok := existing.Actions[action]
|
||||
if !ok {
|
||||
return errors.New(fmt.Sprintf("Action [%v] not available on [%v]", action, existing))
|
||||
}
|
||||
|
||||
_, ok = rancherClient.Types[schemaType]
|
||||
if !ok {
|
||||
return errors.New("Unknown schema type [" + schemaType + "]")
|
||||
}
|
||||
|
||||
var input io.Reader
|
||||
|
||||
if inputObject != nil {
|
||||
bodyContent, err := json.Marshal(inputObject)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if debug {
|
||||
fmt.Println("Request => " + string(bodyContent))
|
||||
}
|
||||
input = bytes.NewBuffer(bodyContent)
|
||||
}
|
||||
|
||||
client := rancherClient.newHttpClient()
|
||||
req, err := http.NewRequest("POST", actionUrl, input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rancherClient.setupRequest(req)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Content-Length", "0")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 300 {
|
||||
return newApiError(resp, actionUrl)
|
||||
}
|
||||
|
||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if debug {
|
||||
fmt.Println("Response <= " + string(byteContent))
|
||||
}
|
||||
|
||||
return json.Unmarshal(byteContent, respObject)
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) GetOpts() *ClientOpts {
|
||||
return rancherClient.Opts
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) GetSchemas() *Schemas {
|
||||
return rancherClient.Schemas
|
||||
}
|
||||
|
||||
func (rancherClient *RancherBaseClientImpl) GetTypes() map[string]Schema {
|
||||
return rancherClient.Types
|
||||
}
|
||||
|
||||
func init() {
|
||||
debug = os.Getenv("RANCHER_CLIENT_DEBUG") == "true"
|
||||
if debug {
|
||||
fmt.Println("Rancher client debug on")
|
||||
}
|
||||
}
|
||||
-186
@@ -1,186 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ACCOUNT_TYPE = "account"
|
||||
)
|
||||
|
||||
type Account struct {
|
||||
Resource
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
ExternalIdType string `json:"externalIdType,omitempty" yaml:"external_id_type,omitempty"`
|
||||
|
||||
Identity string `json:"identity,omitempty" yaml:"identity,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
}
|
||||
|
||||
type AccountCollection struct {
|
||||
Collection
|
||||
Data []Account `json:"data,omitempty"`
|
||||
client *AccountClient
|
||||
}
|
||||
|
||||
type AccountClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AccountOperations interface {
|
||||
List(opts *ListOpts) (*AccountCollection, error)
|
||||
Create(opts *Account) (*Account, error)
|
||||
Update(existing *Account, updates interface{}) (*Account, error)
|
||||
ById(id string) (*Account, error)
|
||||
Delete(container *Account) error
|
||||
|
||||
ActionActivate(*Account) (*Account, error)
|
||||
|
||||
ActionCreate(*Account) (*Account, error)
|
||||
|
||||
ActionDeactivate(*Account) (*Account, error)
|
||||
|
||||
ActionPurge(*Account) (*Account, error)
|
||||
|
||||
ActionRemove(*Account) (*Account, error)
|
||||
|
||||
ActionUpdate(*Account) (*Account, error)
|
||||
|
||||
ActionUpgrade(*Account) (*Account, error)
|
||||
}
|
||||
|
||||
func newAccountClient(rancherClient *RancherClient) *AccountClient {
|
||||
return &AccountClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AccountClient) Create(container *Account) (*Account, error) {
|
||||
resp := &Account{}
|
||||
err := c.rancherClient.doCreate(ACCOUNT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) Update(existing *Account, updates interface{}) (*Account, error) {
|
||||
resp := &Account{}
|
||||
err := c.rancherClient.doUpdate(ACCOUNT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) List(opts *ListOpts) (*AccountCollection, error) {
|
||||
resp := &AccountCollection{}
|
||||
err := c.rancherClient.doList(ACCOUNT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *AccountCollection) Next() (*AccountCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &AccountCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *AccountClient) ById(id string) (*Account, error) {
|
||||
resp := &Account{}
|
||||
err := c.rancherClient.doById(ACCOUNT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) Delete(container *Account) error {
|
||||
return c.rancherClient.doResourceDelete(ACCOUNT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *AccountClient) ActionActivate(resource *Account) (*Account, error) {
|
||||
|
||||
resp := &Account{}
|
||||
|
||||
err := c.rancherClient.doAction(ACCOUNT_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) ActionCreate(resource *Account) (*Account, error) {
|
||||
|
||||
resp := &Account{}
|
||||
|
||||
err := c.rancherClient.doAction(ACCOUNT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) ActionDeactivate(resource *Account) (*Account, error) {
|
||||
|
||||
resp := &Account{}
|
||||
|
||||
err := c.rancherClient.doAction(ACCOUNT_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) ActionPurge(resource *Account) (*Account, error) {
|
||||
|
||||
resp := &Account{}
|
||||
|
||||
err := c.rancherClient.doAction(ACCOUNT_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) ActionRemove(resource *Account) (*Account, error) {
|
||||
|
||||
resp := &Account{}
|
||||
|
||||
err := c.rancherClient.doAction(ACCOUNT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) ActionUpdate(resource *Account) (*Account, error) {
|
||||
|
||||
resp := &Account{}
|
||||
|
||||
err := c.rancherClient.doAction(ACCOUNT_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AccountClient) ActionUpgrade(resource *Account) (*Account, error) {
|
||||
|
||||
resp := &Account{}
|
||||
|
||||
err := c.rancherClient.doAction(ACCOUNT_TYPE, "upgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ACTIVE_SETTING_TYPE = "activeSetting"
|
||||
)
|
||||
|
||||
type ActiveSetting struct {
|
||||
Resource
|
||||
|
||||
ActiveValue interface{} `json:"activeValue,omitempty" yaml:"active_value,omitempty"`
|
||||
|
||||
InDb bool `json:"inDb,omitempty" yaml:"in_db,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Source string `json:"source,omitempty" yaml:"source,omitempty"`
|
||||
|
||||
Value string `json:"value,omitempty" yaml:"value,omitempty"`
|
||||
}
|
||||
|
||||
type ActiveSettingCollection struct {
|
||||
Collection
|
||||
Data []ActiveSetting `json:"data,omitempty"`
|
||||
client *ActiveSettingClient
|
||||
}
|
||||
|
||||
type ActiveSettingClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ActiveSettingOperations interface {
|
||||
List(opts *ListOpts) (*ActiveSettingCollection, error)
|
||||
Create(opts *ActiveSetting) (*ActiveSetting, error)
|
||||
Update(existing *ActiveSetting, updates interface{}) (*ActiveSetting, error)
|
||||
ById(id string) (*ActiveSetting, error)
|
||||
Delete(container *ActiveSetting) error
|
||||
}
|
||||
|
||||
func newActiveSettingClient(rancherClient *RancherClient) *ActiveSettingClient {
|
||||
return &ActiveSettingClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ActiveSettingClient) Create(container *ActiveSetting) (*ActiveSetting, error) {
|
||||
resp := &ActiveSetting{}
|
||||
err := c.rancherClient.doCreate(ACTIVE_SETTING_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ActiveSettingClient) Update(existing *ActiveSetting, updates interface{}) (*ActiveSetting, error) {
|
||||
resp := &ActiveSetting{}
|
||||
err := c.rancherClient.doUpdate(ACTIVE_SETTING_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ActiveSettingClient) List(opts *ListOpts) (*ActiveSettingCollection, error) {
|
||||
resp := &ActiveSettingCollection{}
|
||||
err := c.rancherClient.doList(ACTIVE_SETTING_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ActiveSettingCollection) Next() (*ActiveSettingCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ActiveSettingCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ActiveSettingClient) ById(id string) (*ActiveSetting, error) {
|
||||
resp := &ActiveSetting{}
|
||||
err := c.rancherClient.doById(ACTIVE_SETTING_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ActiveSettingClient) Delete(container *ActiveSetting) error {
|
||||
return c.rancherClient.doResourceDelete(ACTIVE_SETTING_TYPE, &container.Resource)
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_OUTPUTS_INPUT_TYPE = "addOutputsInput"
|
||||
)
|
||||
|
||||
type AddOutputsInput struct {
|
||||
Resource
|
||||
|
||||
Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"`
|
||||
}
|
||||
|
||||
type AddOutputsInputCollection struct {
|
||||
Collection
|
||||
Data []AddOutputsInput `json:"data,omitempty"`
|
||||
client *AddOutputsInputClient
|
||||
}
|
||||
|
||||
type AddOutputsInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddOutputsInputOperations interface {
|
||||
List(opts *ListOpts) (*AddOutputsInputCollection, error)
|
||||
Create(opts *AddOutputsInput) (*AddOutputsInput, error)
|
||||
Update(existing *AddOutputsInput, updates interface{}) (*AddOutputsInput, error)
|
||||
ById(id string) (*AddOutputsInput, error)
|
||||
Delete(container *AddOutputsInput) error
|
||||
}
|
||||
|
||||
func newAddOutputsInputClient(rancherClient *RancherClient) *AddOutputsInputClient {
|
||||
return &AddOutputsInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddOutputsInputClient) Create(container *AddOutputsInput) (*AddOutputsInput, error) {
|
||||
resp := &AddOutputsInput{}
|
||||
err := c.rancherClient.doCreate(ADD_OUTPUTS_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddOutputsInputClient) Update(existing *AddOutputsInput, updates interface{}) (*AddOutputsInput, error) {
|
||||
resp := &AddOutputsInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_OUTPUTS_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddOutputsInputClient) List(opts *ListOpts) (*AddOutputsInputCollection, error) {
|
||||
resp := &AddOutputsInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_OUTPUTS_INPUT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *AddOutputsInputCollection) Next() (*AddOutputsInputCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &AddOutputsInputCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *AddOutputsInputClient) ById(id string) (*AddOutputsInput, error) {
|
||||
resp := &AddOutputsInput{}
|
||||
err := c.rancherClient.doById(ADD_OUTPUTS_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddOutputsInputClient) Delete(container *AddOutputsInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_OUTPUTS_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-79
@@ -1,79 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_REMOVE_SERVICE_LINK_INPUT_TYPE = "addRemoveServiceLinkInput"
|
||||
)
|
||||
|
||||
type AddRemoveServiceLinkInput struct {
|
||||
Resource
|
||||
|
||||
ServiceLink ServiceLink `json:"serviceLink,omitempty" yaml:"service_link,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveServiceLinkInputCollection struct {
|
||||
Collection
|
||||
Data []AddRemoveServiceLinkInput `json:"data,omitempty"`
|
||||
client *AddRemoveServiceLinkInputClient
|
||||
}
|
||||
|
||||
type AddRemoveServiceLinkInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddRemoveServiceLinkInputOperations interface {
|
||||
List(opts *ListOpts) (*AddRemoveServiceLinkInputCollection, error)
|
||||
Create(opts *AddRemoveServiceLinkInput) (*AddRemoveServiceLinkInput, error)
|
||||
Update(existing *AddRemoveServiceLinkInput, updates interface{}) (*AddRemoveServiceLinkInput, error)
|
||||
ById(id string) (*AddRemoveServiceLinkInput, error)
|
||||
Delete(container *AddRemoveServiceLinkInput) error
|
||||
}
|
||||
|
||||
func newAddRemoveServiceLinkInputClient(rancherClient *RancherClient) *AddRemoveServiceLinkInputClient {
|
||||
return &AddRemoveServiceLinkInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddRemoveServiceLinkInputClient) Create(container *AddRemoveServiceLinkInput) (*AddRemoveServiceLinkInput, error) {
|
||||
resp := &AddRemoveServiceLinkInput{}
|
||||
err := c.rancherClient.doCreate(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveServiceLinkInputClient) Update(existing *AddRemoveServiceLinkInput, updates interface{}) (*AddRemoveServiceLinkInput, error) {
|
||||
resp := &AddRemoveServiceLinkInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveServiceLinkInputClient) List(opts *ListOpts) (*AddRemoveServiceLinkInputCollection, error) {
|
||||
resp := &AddRemoveServiceLinkInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *AddRemoveServiceLinkInputCollection) Next() (*AddRemoveServiceLinkInputCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &AddRemoveServiceLinkInputCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *AddRemoveServiceLinkInputClient) ById(id string) (*AddRemoveServiceLinkInput, error) {
|
||||
resp := &AddRemoveServiceLinkInput{}
|
||||
err := c.rancherClient.doById(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveServiceLinkInputClient) Delete(container *AddRemoveServiceLinkInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_REMOVE_SERVICE_LINK_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-206
@@ -1,206 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
AGENT_TYPE = "agent"
|
||||
)
|
||||
|
||||
type Agent struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
ManagedConfig bool `json:"managedConfig,omitempty" yaml:"managed_config,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type AgentCollection struct {
|
||||
Collection
|
||||
Data []Agent `json:"data,omitempty"`
|
||||
client *AgentClient
|
||||
}
|
||||
|
||||
type AgentClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AgentOperations interface {
|
||||
List(opts *ListOpts) (*AgentCollection, error)
|
||||
Create(opts *Agent) (*Agent, error)
|
||||
Update(existing *Agent, updates interface{}) (*Agent, error)
|
||||
ById(id string) (*Agent, error)
|
||||
Delete(container *Agent) error
|
||||
|
||||
ActionActivate(*Agent) (*Agent, error)
|
||||
|
||||
ActionCreate(*Agent) (*Agent, error)
|
||||
|
||||
ActionDeactivate(*Agent) (*Agent, error)
|
||||
|
||||
ActionDisconnect(*Agent) (*Agent, error)
|
||||
|
||||
ActionFinishreconnect(*Agent) (*Agent, error)
|
||||
|
||||
ActionPurge(*Agent) (*Agent, error)
|
||||
|
||||
ActionReconnect(*Agent) (*Agent, error)
|
||||
|
||||
ActionRemove(*Agent) (*Agent, error)
|
||||
|
||||
ActionUpdate(*Agent) (*Agent, error)
|
||||
}
|
||||
|
||||
func newAgentClient(rancherClient *RancherClient) *AgentClient {
|
||||
return &AgentClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AgentClient) Create(container *Agent) (*Agent, error) {
|
||||
resp := &Agent{}
|
||||
err := c.rancherClient.doCreate(AGENT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) Update(existing *Agent, updates interface{}) (*Agent, error) {
|
||||
resp := &Agent{}
|
||||
err := c.rancherClient.doUpdate(AGENT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) List(opts *ListOpts) (*AgentCollection, error) {
|
||||
resp := &AgentCollection{}
|
||||
err := c.rancherClient.doList(AGENT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *AgentCollection) Next() (*AgentCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &AgentCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *AgentClient) ById(id string) (*Agent, error) {
|
||||
resp := &Agent{}
|
||||
err := c.rancherClient.doById(AGENT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) Delete(container *Agent) error {
|
||||
return c.rancherClient.doResourceDelete(AGENT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionActivate(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionCreate(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionDeactivate(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionDisconnect(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "disconnect", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionFinishreconnect(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "finishreconnect", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionPurge(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionReconnect(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "reconnect", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionRemove(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AgentClient) ActionUpdate(resource *Agent) (*Agent, error) {
|
||||
|
||||
resp := &Agent{}
|
||||
|
||||
err := c.rancherClient.doAction(AGENT_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-137
@@ -1,137 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
AMAZONEC2CONFIG_TYPE = "amazonec2Config"
|
||||
)
|
||||
|
||||
type Amazonec2Config struct {
|
||||
Resource
|
||||
|
||||
AccessKey string `json:"accessKey,omitempty" yaml:"access_key,omitempty"`
|
||||
|
||||
Ami string `json:"ami,omitempty" yaml:"ami,omitempty"`
|
||||
|
||||
BlockDurationMinutes string `json:"blockDurationMinutes,omitempty" yaml:"block_duration_minutes,omitempty"`
|
||||
|
||||
DeviceName string `json:"deviceName,omitempty" yaml:"device_name,omitempty"`
|
||||
|
||||
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
|
||||
|
||||
IamInstanceProfile string `json:"iamInstanceProfile,omitempty" yaml:"iam_instance_profile,omitempty"`
|
||||
|
||||
InsecureTransport bool `json:"insecureTransport,omitempty" yaml:"insecure_transport,omitempty"`
|
||||
|
||||
InstanceType string `json:"instanceType,omitempty" yaml:"instance_type,omitempty"`
|
||||
|
||||
KeypairName string `json:"keypairName,omitempty" yaml:"keypair_name,omitempty"`
|
||||
|
||||
Monitoring bool `json:"monitoring,omitempty" yaml:"monitoring,omitempty"`
|
||||
|
||||
OpenPort []string `json:"openPort,omitempty" yaml:"open_port,omitempty"`
|
||||
|
||||
PrivateAddressOnly bool `json:"privateAddressOnly,omitempty" yaml:"private_address_only,omitempty"`
|
||||
|
||||
Region string `json:"region,omitempty" yaml:"region,omitempty"`
|
||||
|
||||
RequestSpotInstance bool `json:"requestSpotInstance,omitempty" yaml:"request_spot_instance,omitempty"`
|
||||
|
||||
Retries string `json:"retries,omitempty" yaml:"retries,omitempty"`
|
||||
|
||||
RootSize string `json:"rootSize,omitempty" yaml:"root_size,omitempty"`
|
||||
|
||||
SecretKey string `json:"secretKey,omitempty" yaml:"secret_key,omitempty"`
|
||||
|
||||
SecurityGroup []string `json:"securityGroup,omitempty" yaml:"security_group,omitempty"`
|
||||
|
||||
SessionToken string `json:"sessionToken,omitempty" yaml:"session_token,omitempty"`
|
||||
|
||||
SpotPrice string `json:"spotPrice,omitempty" yaml:"spot_price,omitempty"`
|
||||
|
||||
SshKeypath string `json:"sshKeypath,omitempty" yaml:"ssh_keypath,omitempty"`
|
||||
|
||||
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
|
||||
|
||||
SubnetId string `json:"subnetId,omitempty" yaml:"subnet_id,omitempty"`
|
||||
|
||||
Tags string `json:"tags,omitempty" yaml:"tags,omitempty"`
|
||||
|
||||
UseEbsOptimizedInstance bool `json:"useEbsOptimizedInstance,omitempty" yaml:"use_ebs_optimized_instance,omitempty"`
|
||||
|
||||
UsePrivateAddress bool `json:"usePrivateAddress,omitempty" yaml:"use_private_address,omitempty"`
|
||||
|
||||
Userdata string `json:"userdata,omitempty" yaml:"userdata,omitempty"`
|
||||
|
||||
VolumeType string `json:"volumeType,omitempty" yaml:"volume_type,omitempty"`
|
||||
|
||||
VpcId string `json:"vpcId,omitempty" yaml:"vpc_id,omitempty"`
|
||||
|
||||
Zone string `json:"zone,omitempty" yaml:"zone,omitempty"`
|
||||
}
|
||||
|
||||
type Amazonec2ConfigCollection struct {
|
||||
Collection
|
||||
Data []Amazonec2Config `json:"data,omitempty"`
|
||||
client *Amazonec2ConfigClient
|
||||
}
|
||||
|
||||
type Amazonec2ConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type Amazonec2ConfigOperations interface {
|
||||
List(opts *ListOpts) (*Amazonec2ConfigCollection, error)
|
||||
Create(opts *Amazonec2Config) (*Amazonec2Config, error)
|
||||
Update(existing *Amazonec2Config, updates interface{}) (*Amazonec2Config, error)
|
||||
ById(id string) (*Amazonec2Config, error)
|
||||
Delete(container *Amazonec2Config) error
|
||||
}
|
||||
|
||||
func newAmazonec2ConfigClient(rancherClient *RancherClient) *Amazonec2ConfigClient {
|
||||
return &Amazonec2ConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Amazonec2ConfigClient) Create(container *Amazonec2Config) (*Amazonec2Config, error) {
|
||||
resp := &Amazonec2Config{}
|
||||
err := c.rancherClient.doCreate(AMAZONEC2CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *Amazonec2ConfigClient) Update(existing *Amazonec2Config, updates interface{}) (*Amazonec2Config, error) {
|
||||
resp := &Amazonec2Config{}
|
||||
err := c.rancherClient.doUpdate(AMAZONEC2CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *Amazonec2ConfigClient) List(opts *ListOpts) (*Amazonec2ConfigCollection, error) {
|
||||
resp := &Amazonec2ConfigCollection{}
|
||||
err := c.rancherClient.doList(AMAZONEC2CONFIG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *Amazonec2ConfigCollection) Next() (*Amazonec2ConfigCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &Amazonec2ConfigCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *Amazonec2ConfigClient) ById(id string) (*Amazonec2Config, error) {
|
||||
resp := &Amazonec2Config{}
|
||||
err := c.rancherClient.doById(AMAZONEC2CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *Amazonec2ConfigClient) Delete(container *Amazonec2Config) error {
|
||||
return c.rancherClient.doResourceDelete(AMAZONEC2CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-173
@@ -1,173 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
API_KEY_TYPE = "apiKey"
|
||||
)
|
||||
|
||||
type ApiKey struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ApiKeyCollection struct {
|
||||
Collection
|
||||
Data []ApiKey `json:"data,omitempty"`
|
||||
client *ApiKeyClient
|
||||
}
|
||||
|
||||
type ApiKeyClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ApiKeyOperations interface {
|
||||
List(opts *ListOpts) (*ApiKeyCollection, error)
|
||||
Create(opts *ApiKey) (*ApiKey, error)
|
||||
Update(existing *ApiKey, updates interface{}) (*ApiKey, error)
|
||||
ById(id string) (*ApiKey, error)
|
||||
Delete(container *ApiKey) error
|
||||
|
||||
ActionActivate(*ApiKey) (*Credential, error)
|
||||
|
||||
ActionCreate(*ApiKey) (*Credential, error)
|
||||
|
||||
ActionDeactivate(*ApiKey) (*Credential, error)
|
||||
|
||||
ActionPurge(*ApiKey) (*Credential, error)
|
||||
|
||||
ActionRemove(*ApiKey) (*Credential, error)
|
||||
|
||||
ActionUpdate(*ApiKey) (*Credential, error)
|
||||
}
|
||||
|
||||
func newApiKeyClient(rancherClient *RancherClient) *ApiKeyClient {
|
||||
return &ApiKeyClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) Create(container *ApiKey) (*ApiKey, error) {
|
||||
resp := &ApiKey{}
|
||||
err := c.rancherClient.doCreate(API_KEY_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) Update(existing *ApiKey, updates interface{}) (*ApiKey, error) {
|
||||
resp := &ApiKey{}
|
||||
err := c.rancherClient.doUpdate(API_KEY_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) List(opts *ListOpts) (*ApiKeyCollection, error) {
|
||||
resp := &ApiKeyCollection{}
|
||||
err := c.rancherClient.doList(API_KEY_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ApiKeyCollection) Next() (*ApiKeyCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ApiKeyCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) ById(id string) (*ApiKey, error) {
|
||||
resp := &ApiKey{}
|
||||
err := c.rancherClient.doById(API_KEY_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) Delete(container *ApiKey) error {
|
||||
return c.rancherClient.doResourceDelete(API_KEY_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) ActionActivate(resource *ApiKey) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(API_KEY_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) ActionCreate(resource *ApiKey) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(API_KEY_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) ActionDeactivate(resource *ApiKey) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(API_KEY_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) ActionPurge(resource *ApiKey) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(API_KEY_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) ActionRemove(resource *ApiKey) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(API_KEY_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ApiKeyClient) ActionUpdate(resource *ApiKey) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(API_KEY_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-105
@@ -1,105 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
AUDIT_LOG_TYPE = "auditLog"
|
||||
)
|
||||
|
||||
type AuditLog struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
AuthType string `json:"authType,omitempty" yaml:"auth_type,omitempty"`
|
||||
|
||||
AuthenticatedAsAccountId string `json:"authenticatedAsAccountId,omitempty" yaml:"authenticated_as_account_id,omitempty"`
|
||||
|
||||
AuthenticatedAsIdentityId string `json:"authenticatedAsIdentityId,omitempty" yaml:"authenticated_as_identity_id,omitempty"`
|
||||
|
||||
ClientIp string `json:"clientIp,omitempty" yaml:"client_ip,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
RequestObject string `json:"requestObject,omitempty" yaml:"request_object,omitempty"`
|
||||
|
||||
ResourceId int64 `json:"resourceId,omitempty" yaml:"resource_id,omitempty"`
|
||||
|
||||
ResourceType string `json:"resourceType,omitempty" yaml:"resource_type,omitempty"`
|
||||
|
||||
ResponseCode string `json:"responseCode,omitempty" yaml:"response_code,omitempty"`
|
||||
|
||||
ResponseObject string `json:"responseObject,omitempty" yaml:"response_object,omitempty"`
|
||||
}
|
||||
|
||||
type AuditLogCollection struct {
|
||||
Collection
|
||||
Data []AuditLog `json:"data,omitempty"`
|
||||
client *AuditLogClient
|
||||
}
|
||||
|
||||
type AuditLogClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AuditLogOperations interface {
|
||||
List(opts *ListOpts) (*AuditLogCollection, error)
|
||||
Create(opts *AuditLog) (*AuditLog, error)
|
||||
Update(existing *AuditLog, updates interface{}) (*AuditLog, error)
|
||||
ById(id string) (*AuditLog, error)
|
||||
Delete(container *AuditLog) error
|
||||
}
|
||||
|
||||
func newAuditLogClient(rancherClient *RancherClient) *AuditLogClient {
|
||||
return &AuditLogClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AuditLogClient) Create(container *AuditLog) (*AuditLog, error) {
|
||||
resp := &AuditLog{}
|
||||
err := c.rancherClient.doCreate(AUDIT_LOG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AuditLogClient) Update(existing *AuditLog, updates interface{}) (*AuditLog, error) {
|
||||
resp := &AuditLog{}
|
||||
err := c.rancherClient.doUpdate(AUDIT_LOG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AuditLogClient) List(opts *ListOpts) (*AuditLogCollection, error) {
|
||||
resp := &AuditLogCollection{}
|
||||
err := c.rancherClient.doList(AUDIT_LOG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *AuditLogCollection) Next() (*AuditLogCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &AuditLogCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *AuditLogClient) ById(id string) (*AuditLog, error) {
|
||||
resp := &AuditLog{}
|
||||
err := c.rancherClient.doById(AUDIT_LOG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AuditLogClient) Delete(container *AuditLog) error {
|
||||
return c.rancherClient.doResourceDelete(AUDIT_LOG_TYPE, &container.Resource)
|
||||
}
|
||||
-121
@@ -1,121 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
AZURE_CONFIG_TYPE = "azureConfig"
|
||||
)
|
||||
|
||||
type AzureConfig struct {
|
||||
Resource
|
||||
|
||||
AvailabilitySet string `json:"availabilitySet,omitempty" yaml:"availability_set,omitempty"`
|
||||
|
||||
ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"`
|
||||
|
||||
ClientSecret string `json:"clientSecret,omitempty" yaml:"client_secret,omitempty"`
|
||||
|
||||
CustomData string `json:"customData,omitempty" yaml:"custom_data,omitempty"`
|
||||
|
||||
Dns string `json:"dns,omitempty" yaml:"dns,omitempty"`
|
||||
|
||||
DockerPort string `json:"dockerPort,omitempty" yaml:"docker_port,omitempty"`
|
||||
|
||||
Environment string `json:"environment,omitempty" yaml:"environment,omitempty"`
|
||||
|
||||
Image string `json:"image,omitempty" yaml:"image,omitempty"`
|
||||
|
||||
Location string `json:"location,omitempty" yaml:"location,omitempty"`
|
||||
|
||||
NoPublicIp bool `json:"noPublicIp,omitempty" yaml:"no_public_ip,omitempty"`
|
||||
|
||||
OpenPort []string `json:"openPort,omitempty" yaml:"open_port,omitempty"`
|
||||
|
||||
PrivateIpAddress string `json:"privateIpAddress,omitempty" yaml:"private_ip_address,omitempty"`
|
||||
|
||||
ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resource_group,omitempty"`
|
||||
|
||||
Size string `json:"size,omitempty" yaml:"size,omitempty"`
|
||||
|
||||
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
|
||||
|
||||
StaticPublicIp bool `json:"staticPublicIp,omitempty" yaml:"static_public_ip,omitempty"`
|
||||
|
||||
StorageType string `json:"storageType,omitempty" yaml:"storage_type,omitempty"`
|
||||
|
||||
Subnet string `json:"subnet,omitempty" yaml:"subnet,omitempty"`
|
||||
|
||||
SubnetPrefix string `json:"subnetPrefix,omitempty" yaml:"subnet_prefix,omitempty"`
|
||||
|
||||
SubscriptionId string `json:"subscriptionId,omitempty" yaml:"subscription_id,omitempty"`
|
||||
|
||||
UsePrivateIp bool `json:"usePrivateIp,omitempty" yaml:"use_private_ip,omitempty"`
|
||||
|
||||
Vnet string `json:"vnet,omitempty" yaml:"vnet,omitempty"`
|
||||
}
|
||||
|
||||
type AzureConfigCollection struct {
|
||||
Collection
|
||||
Data []AzureConfig `json:"data,omitempty"`
|
||||
client *AzureConfigClient
|
||||
}
|
||||
|
||||
type AzureConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AzureConfigOperations interface {
|
||||
List(opts *ListOpts) (*AzureConfigCollection, error)
|
||||
Create(opts *AzureConfig) (*AzureConfig, error)
|
||||
Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error)
|
||||
ById(id string) (*AzureConfig, error)
|
||||
Delete(container *AzureConfig) error
|
||||
}
|
||||
|
||||
func newAzureConfigClient(rancherClient *RancherClient) *AzureConfigClient {
|
||||
return &AzureConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AzureConfigClient) Create(container *AzureConfig) (*AzureConfig, error) {
|
||||
resp := &AzureConfig{}
|
||||
err := c.rancherClient.doCreate(AZURE_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AzureConfigClient) Update(existing *AzureConfig, updates interface{}) (*AzureConfig, error) {
|
||||
resp := &AzureConfig{}
|
||||
err := c.rancherClient.doUpdate(AZURE_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AzureConfigClient) List(opts *ListOpts) (*AzureConfigCollection, error) {
|
||||
resp := &AzureConfigCollection{}
|
||||
err := c.rancherClient.doList(AZURE_CONFIG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *AzureConfigCollection) Next() (*AzureConfigCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &AzureConfigCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *AzureConfigClient) ById(id string) (*AzureConfig, error) {
|
||||
resp := &AzureConfig{}
|
||||
err := c.rancherClient.doById(AZURE_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AzureConfigClient) Delete(container *AzureConfig) error {
|
||||
return c.rancherClient.doResourceDelete(AZURE_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
AZUREADCONFIG_TYPE = "azureadconfig"
|
||||
)
|
||||
|
||||
type Azureadconfig struct {
|
||||
Resource
|
||||
|
||||
AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"`
|
||||
|
||||
AdminAccountPassword string `json:"adminAccountPassword,omitempty" yaml:"admin_account_password,omitempty"`
|
||||
|
||||
AdminAccountUsername string `json:"adminAccountUsername,omitempty" yaml:"admin_account_username,omitempty"`
|
||||
|
||||
ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"`
|
||||
|
||||
Domain string `json:"domain,omitempty" yaml:"domain,omitempty"`
|
||||
|
||||
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
TenantId string `json:"tenantId,omitempty" yaml:"tenant_id,omitempty"`
|
||||
}
|
||||
|
||||
type AzureadconfigCollection struct {
|
||||
Collection
|
||||
Data []Azureadconfig `json:"data,omitempty"`
|
||||
client *AzureadconfigClient
|
||||
}
|
||||
|
||||
type AzureadconfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AzureadconfigOperations interface {
|
||||
List(opts *ListOpts) (*AzureadconfigCollection, error)
|
||||
Create(opts *Azureadconfig) (*Azureadconfig, error)
|
||||
Update(existing *Azureadconfig, updates interface{}) (*Azureadconfig, error)
|
||||
ById(id string) (*Azureadconfig, error)
|
||||
Delete(container *Azureadconfig) error
|
||||
}
|
||||
|
||||
func newAzureadconfigClient(rancherClient *RancherClient) *AzureadconfigClient {
|
||||
return &AzureadconfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AzureadconfigClient) Create(container *Azureadconfig) (*Azureadconfig, error) {
|
||||
resp := &Azureadconfig{}
|
||||
err := c.rancherClient.doCreate(AZUREADCONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AzureadconfigClient) Update(existing *Azureadconfig, updates interface{}) (*Azureadconfig, error) {
|
||||
resp := &Azureadconfig{}
|
||||
err := c.rancherClient.doUpdate(AZUREADCONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AzureadconfigClient) List(opts *ListOpts) (*AzureadconfigCollection, error) {
|
||||
resp := &AzureadconfigCollection{}
|
||||
err := c.rancherClient.doList(AZUREADCONFIG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *AzureadconfigCollection) Next() (*AzureadconfigCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &AzureadconfigCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *AzureadconfigClient) ById(id string) (*Azureadconfig, error) {
|
||||
resp := &Azureadconfig{}
|
||||
err := c.rancherClient.doById(AZUREADCONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AzureadconfigClient) Delete(container *Azureadconfig) error {
|
||||
return c.rancherClient.doResourceDelete(AZUREADCONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
BACKUP_TYPE = "backup"
|
||||
)
|
||||
|
||||
type Backup struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
BackupTargetId string `json:"backupTargetId,omitempty" yaml:"backup_target_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
SnapshotId string `json:"snapshotId,omitempty" yaml:"snapshot_id,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
|
||||
VolumeId string `json:"volumeId,omitempty" yaml:"volume_id,omitempty"`
|
||||
}
|
||||
|
||||
type BackupCollection struct {
|
||||
Collection
|
||||
Data []Backup `json:"data,omitempty"`
|
||||
client *BackupClient
|
||||
}
|
||||
|
||||
type BackupClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type BackupOperations interface {
|
||||
List(opts *ListOpts) (*BackupCollection, error)
|
||||
Create(opts *Backup) (*Backup, error)
|
||||
Update(existing *Backup, updates interface{}) (*Backup, error)
|
||||
ById(id string) (*Backup, error)
|
||||
Delete(container *Backup) error
|
||||
|
||||
ActionCreate(*Backup) (*Backup, error)
|
||||
|
||||
ActionRemove(*Backup) (*Backup, error)
|
||||
}
|
||||
|
||||
func newBackupClient(rancherClient *RancherClient) *BackupClient {
|
||||
return &BackupClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *BackupClient) Create(container *Backup) (*Backup, error) {
|
||||
resp := &Backup{}
|
||||
err := c.rancherClient.doCreate(BACKUP_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupClient) Update(existing *Backup, updates interface{}) (*Backup, error) {
|
||||
resp := &Backup{}
|
||||
err := c.rancherClient.doUpdate(BACKUP_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupClient) List(opts *ListOpts) (*BackupCollection, error) {
|
||||
resp := &BackupCollection{}
|
||||
err := c.rancherClient.doList(BACKUP_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *BackupCollection) Next() (*BackupCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &BackupCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *BackupClient) ById(id string) (*Backup, error) {
|
||||
resp := &Backup{}
|
||||
err := c.rancherClient.doById(BACKUP_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupClient) Delete(container *Backup) error {
|
||||
return c.rancherClient.doResourceDelete(BACKUP_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *BackupClient) ActionCreate(resource *Backup) (*Backup, error) {
|
||||
|
||||
resp := &Backup{}
|
||||
|
||||
err := c.rancherClient.doAction(BACKUP_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupClient) ActionRemove(resource *Backup) (*Backup, error) {
|
||||
|
||||
resp := &Backup{}
|
||||
|
||||
err := c.rancherClient.doAction(BACKUP_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
BACKUP_TARGET_TYPE = "backupTarget"
|
||||
)
|
||||
|
||||
type BackupTarget struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
NfsConfig *NfsConfig `json:"nfsConfig,omitempty" yaml:"nfs_config,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type BackupTargetCollection struct {
|
||||
Collection
|
||||
Data []BackupTarget `json:"data,omitempty"`
|
||||
client *BackupTargetClient
|
||||
}
|
||||
|
||||
type BackupTargetClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type BackupTargetOperations interface {
|
||||
List(opts *ListOpts) (*BackupTargetCollection, error)
|
||||
Create(opts *BackupTarget) (*BackupTarget, error)
|
||||
Update(existing *BackupTarget, updates interface{}) (*BackupTarget, error)
|
||||
ById(id string) (*BackupTarget, error)
|
||||
Delete(container *BackupTarget) error
|
||||
|
||||
ActionCreate(*BackupTarget) (*BackupTarget, error)
|
||||
|
||||
ActionRemove(*BackupTarget) (*BackupTarget, error)
|
||||
}
|
||||
|
||||
func newBackupTargetClient(rancherClient *RancherClient) *BackupTargetClient {
|
||||
return &BackupTargetClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *BackupTargetClient) Create(container *BackupTarget) (*BackupTarget, error) {
|
||||
resp := &BackupTarget{}
|
||||
err := c.rancherClient.doCreate(BACKUP_TARGET_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupTargetClient) Update(existing *BackupTarget, updates interface{}) (*BackupTarget, error) {
|
||||
resp := &BackupTarget{}
|
||||
err := c.rancherClient.doUpdate(BACKUP_TARGET_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupTargetClient) List(opts *ListOpts) (*BackupTargetCollection, error) {
|
||||
resp := &BackupTargetCollection{}
|
||||
err := c.rancherClient.doList(BACKUP_TARGET_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *BackupTargetCollection) Next() (*BackupTargetCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &BackupTargetCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *BackupTargetClient) ById(id string) (*BackupTarget, error) {
|
||||
resp := &BackupTarget{}
|
||||
err := c.rancherClient.doById(BACKUP_TARGET_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupTargetClient) Delete(container *BackupTarget) error {
|
||||
return c.rancherClient.doResourceDelete(BACKUP_TARGET_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *BackupTargetClient) ActionCreate(resource *BackupTarget) (*BackupTarget, error) {
|
||||
|
||||
resp := &BackupTarget{}
|
||||
|
||||
err := c.rancherClient.doAction(BACKUP_TARGET_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BackupTargetClient) ActionRemove(resource *BackupTarget) (*BackupTarget, error) {
|
||||
|
||||
resp := &BackupTarget{}
|
||||
|
||||
err := c.rancherClient.doAction(BACKUP_TARGET_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
BASE_MACHINE_CONFIG_TYPE = "baseMachineConfig"
|
||||
)
|
||||
|
||||
type BaseMachineConfig struct {
|
||||
Resource
|
||||
}
|
||||
|
||||
type BaseMachineConfigCollection struct {
|
||||
Collection
|
||||
Data []BaseMachineConfig `json:"data,omitempty"`
|
||||
client *BaseMachineConfigClient
|
||||
}
|
||||
|
||||
type BaseMachineConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type BaseMachineConfigOperations interface {
|
||||
List(opts *ListOpts) (*BaseMachineConfigCollection, error)
|
||||
Create(opts *BaseMachineConfig) (*BaseMachineConfig, error)
|
||||
Update(existing *BaseMachineConfig, updates interface{}) (*BaseMachineConfig, error)
|
||||
ById(id string) (*BaseMachineConfig, error)
|
||||
Delete(container *BaseMachineConfig) error
|
||||
}
|
||||
|
||||
func newBaseMachineConfigClient(rancherClient *RancherClient) *BaseMachineConfigClient {
|
||||
return &BaseMachineConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *BaseMachineConfigClient) Create(container *BaseMachineConfig) (*BaseMachineConfig, error) {
|
||||
resp := &BaseMachineConfig{}
|
||||
err := c.rancherClient.doCreate(BASE_MACHINE_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BaseMachineConfigClient) Update(existing *BaseMachineConfig, updates interface{}) (*BaseMachineConfig, error) {
|
||||
resp := &BaseMachineConfig{}
|
||||
err := c.rancherClient.doUpdate(BASE_MACHINE_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BaseMachineConfigClient) List(opts *ListOpts) (*BaseMachineConfigCollection, error) {
|
||||
resp := &BaseMachineConfigCollection{}
|
||||
err := c.rancherClient.doList(BASE_MACHINE_CONFIG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *BaseMachineConfigCollection) Next() (*BaseMachineConfigCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &BaseMachineConfigCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *BaseMachineConfigClient) ById(id string) (*BaseMachineConfig, error) {
|
||||
resp := &BaseMachineConfig{}
|
||||
err := c.rancherClient.doById(BASE_MACHINE_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BaseMachineConfigClient) Delete(container *BaseMachineConfig) error {
|
||||
return c.rancherClient.doResourceDelete(BASE_MACHINE_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
BINDING_TYPE = "binding"
|
||||
)
|
||||
|
||||
type Binding struct {
|
||||
Resource
|
||||
|
||||
Services map[string]interface{} `json:"services,omitempty" yaml:"services,omitempty"`
|
||||
}
|
||||
|
||||
type BindingCollection struct {
|
||||
Collection
|
||||
Data []Binding `json:"data,omitempty"`
|
||||
client *BindingClient
|
||||
}
|
||||
|
||||
type BindingClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type BindingOperations interface {
|
||||
List(opts *ListOpts) (*BindingCollection, error)
|
||||
Create(opts *Binding) (*Binding, error)
|
||||
Update(existing *Binding, updates interface{}) (*Binding, error)
|
||||
ById(id string) (*Binding, error)
|
||||
Delete(container *Binding) error
|
||||
}
|
||||
|
||||
func newBindingClient(rancherClient *RancherClient) *BindingClient {
|
||||
return &BindingClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *BindingClient) Create(container *Binding) (*Binding, error) {
|
||||
resp := &Binding{}
|
||||
err := c.rancherClient.doCreate(BINDING_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BindingClient) Update(existing *Binding, updates interface{}) (*Binding, error) {
|
||||
resp := &Binding{}
|
||||
err := c.rancherClient.doUpdate(BINDING_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BindingClient) List(opts *ListOpts) (*BindingCollection, error) {
|
||||
resp := &BindingCollection{}
|
||||
err := c.rancherClient.doList(BINDING_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *BindingCollection) Next() (*BindingCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &BindingCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *BindingClient) ById(id string) (*Binding, error) {
|
||||
resp := &Binding{}
|
||||
err := c.rancherClient.doById(BINDING_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BindingClient) Delete(container *Binding) error {
|
||||
return c.rancherClient.doResourceDelete(BINDING_TYPE, &container.Resource)
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
BLKIO_DEVICE_OPTION_TYPE = "blkioDeviceOption"
|
||||
)
|
||||
|
||||
type BlkioDeviceOption struct {
|
||||
Resource
|
||||
|
||||
ReadBps int64 `json:"readBps,omitempty" yaml:"read_bps,omitempty"`
|
||||
|
||||
ReadIops int64 `json:"readIops,omitempty" yaml:"read_iops,omitempty"`
|
||||
|
||||
Weight int64 `json:"weight,omitempty" yaml:"weight,omitempty"`
|
||||
|
||||
WriteBps int64 `json:"writeBps,omitempty" yaml:"write_bps,omitempty"`
|
||||
|
||||
WriteIops int64 `json:"writeIops,omitempty" yaml:"write_iops,omitempty"`
|
||||
}
|
||||
|
||||
type BlkioDeviceOptionCollection struct {
|
||||
Collection
|
||||
Data []BlkioDeviceOption `json:"data,omitempty"`
|
||||
client *BlkioDeviceOptionClient
|
||||
}
|
||||
|
||||
type BlkioDeviceOptionClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type BlkioDeviceOptionOperations interface {
|
||||
List(opts *ListOpts) (*BlkioDeviceOptionCollection, error)
|
||||
Create(opts *BlkioDeviceOption) (*BlkioDeviceOption, error)
|
||||
Update(existing *BlkioDeviceOption, updates interface{}) (*BlkioDeviceOption, error)
|
||||
ById(id string) (*BlkioDeviceOption, error)
|
||||
Delete(container *BlkioDeviceOption) error
|
||||
}
|
||||
|
||||
func newBlkioDeviceOptionClient(rancherClient *RancherClient) *BlkioDeviceOptionClient {
|
||||
return &BlkioDeviceOptionClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *BlkioDeviceOptionClient) Create(container *BlkioDeviceOption) (*BlkioDeviceOption, error) {
|
||||
resp := &BlkioDeviceOption{}
|
||||
err := c.rancherClient.doCreate(BLKIO_DEVICE_OPTION_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BlkioDeviceOptionClient) Update(existing *BlkioDeviceOption, updates interface{}) (*BlkioDeviceOption, error) {
|
||||
resp := &BlkioDeviceOption{}
|
||||
err := c.rancherClient.doUpdate(BLKIO_DEVICE_OPTION_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BlkioDeviceOptionClient) List(opts *ListOpts) (*BlkioDeviceOptionCollection, error) {
|
||||
resp := &BlkioDeviceOptionCollection{}
|
||||
err := c.rancherClient.doList(BLKIO_DEVICE_OPTION_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *BlkioDeviceOptionCollection) Next() (*BlkioDeviceOptionCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &BlkioDeviceOptionCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *BlkioDeviceOptionClient) ById(id string) (*BlkioDeviceOption, error) {
|
||||
resp := &BlkioDeviceOption{}
|
||||
err := c.rancherClient.doById(BLKIO_DEVICE_OPTION_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *BlkioDeviceOptionClient) Delete(container *BlkioDeviceOption) error {
|
||||
return c.rancherClient.doResourceDelete(BLKIO_DEVICE_OPTION_TYPE, &container.Resource)
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CATALOG_TEMPLATE_TYPE = "catalogTemplate"
|
||||
)
|
||||
|
||||
type CatalogTemplate struct {
|
||||
Resource
|
||||
|
||||
Answers map[string]interface{} `json:"answers,omitempty" yaml:"answers,omitempty"`
|
||||
|
||||
Binding Binding `json:"binding,omitempty" yaml:"binding,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
DockerCompose string `json:"dockerCompose,omitempty" yaml:"docker_compose,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"`
|
||||
|
||||
TemplateId string `json:"templateId,omitempty" yaml:"template_id,omitempty"`
|
||||
|
||||
TemplateVersionId string `json:"templateVersionId,omitempty" yaml:"template_version_id,omitempty"`
|
||||
}
|
||||
|
||||
type CatalogTemplateCollection struct {
|
||||
Collection
|
||||
Data []CatalogTemplate `json:"data,omitempty"`
|
||||
client *CatalogTemplateClient
|
||||
}
|
||||
|
||||
type CatalogTemplateClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type CatalogTemplateOperations interface {
|
||||
List(opts *ListOpts) (*CatalogTemplateCollection, error)
|
||||
Create(opts *CatalogTemplate) (*CatalogTemplate, error)
|
||||
Update(existing *CatalogTemplate, updates interface{}) (*CatalogTemplate, error)
|
||||
ById(id string) (*CatalogTemplate, error)
|
||||
Delete(container *CatalogTemplate) error
|
||||
}
|
||||
|
||||
func newCatalogTemplateClient(rancherClient *RancherClient) *CatalogTemplateClient {
|
||||
return &CatalogTemplateClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CatalogTemplateClient) Create(container *CatalogTemplate) (*CatalogTemplate, error) {
|
||||
resp := &CatalogTemplate{}
|
||||
err := c.rancherClient.doCreate(CATALOG_TEMPLATE_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CatalogTemplateClient) Update(existing *CatalogTemplate, updates interface{}) (*CatalogTemplate, error) {
|
||||
resp := &CatalogTemplate{}
|
||||
err := c.rancherClient.doUpdate(CATALOG_TEMPLATE_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CatalogTemplateClient) List(opts *ListOpts) (*CatalogTemplateCollection, error) {
|
||||
resp := &CatalogTemplateCollection{}
|
||||
err := c.rancherClient.doList(CATALOG_TEMPLATE_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *CatalogTemplateCollection) Next() (*CatalogTemplateCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &CatalogTemplateCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *CatalogTemplateClient) ById(id string) (*CatalogTemplate, error) {
|
||||
resp := &CatalogTemplate{}
|
||||
err := c.rancherClient.doById(CATALOG_TEMPLATE_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CatalogTemplateClient) Delete(container *CatalogTemplate) error {
|
||||
return c.rancherClient.doResourceDelete(CATALOG_TEMPLATE_TYPE, &container.Resource)
|
||||
}
|
||||
-162
@@ -1,162 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CERTIFICATE_TYPE = "certificate"
|
||||
)
|
||||
|
||||
type Certificate struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
|
||||
|
||||
CN string `json:"cN,omitempty" yaml:"cn,omitempty"`
|
||||
|
||||
Cert string `json:"cert,omitempty" yaml:"cert,omitempty"`
|
||||
|
||||
CertChain string `json:"certChain,omitempty" yaml:"cert_chain,omitempty"`
|
||||
|
||||
CertFingerprint string `json:"certFingerprint,omitempty" yaml:"cert_fingerprint,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
ExpiresAt string `json:"expiresAt,omitempty" yaml:"expires_at,omitempty"`
|
||||
|
||||
IssuedAt string `json:"issuedAt,omitempty" yaml:"issued_at,omitempty"`
|
||||
|
||||
Issuer string `json:"issuer,omitempty" yaml:"issuer,omitempty"`
|
||||
|
||||
Key string `json:"key,omitempty" yaml:"key,omitempty"`
|
||||
|
||||
KeySize int64 `json:"keySize,omitempty" yaml:"key_size,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
SerialNumber string `json:"serialNumber,omitempty" yaml:"serial_number,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
SubjectAlternativeNames []string `json:"subjectAlternativeNames,omitempty" yaml:"subject_alternative_names,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
}
|
||||
|
||||
type CertificateCollection struct {
|
||||
Collection
|
||||
Data []Certificate `json:"data,omitempty"`
|
||||
client *CertificateClient
|
||||
}
|
||||
|
||||
type CertificateClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type CertificateOperations interface {
|
||||
List(opts *ListOpts) (*CertificateCollection, error)
|
||||
Create(opts *Certificate) (*Certificate, error)
|
||||
Update(existing *Certificate, updates interface{}) (*Certificate, error)
|
||||
ById(id string) (*Certificate, error)
|
||||
Delete(container *Certificate) error
|
||||
|
||||
ActionCreate(*Certificate) (*Certificate, error)
|
||||
|
||||
ActionRemove(*Certificate) (*Certificate, error)
|
||||
|
||||
ActionUpdate(*Certificate) (*Certificate, error)
|
||||
}
|
||||
|
||||
func newCertificateClient(rancherClient *RancherClient) *CertificateClient {
|
||||
return &CertificateClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CertificateClient) Create(container *Certificate) (*Certificate, error) {
|
||||
resp := &Certificate{}
|
||||
err := c.rancherClient.doCreate(CERTIFICATE_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CertificateClient) Update(existing *Certificate, updates interface{}) (*Certificate, error) {
|
||||
resp := &Certificate{}
|
||||
err := c.rancherClient.doUpdate(CERTIFICATE_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CertificateClient) List(opts *ListOpts) (*CertificateCollection, error) {
|
||||
resp := &CertificateCollection{}
|
||||
err := c.rancherClient.doList(CERTIFICATE_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *CertificateCollection) Next() (*CertificateCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &CertificateCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *CertificateClient) ById(id string) (*Certificate, error) {
|
||||
resp := &Certificate{}
|
||||
err := c.rancherClient.doById(CERTIFICATE_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CertificateClient) Delete(container *Certificate) error {
|
||||
return c.rancherClient.doResourceDelete(CERTIFICATE_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *CertificateClient) ActionCreate(resource *Certificate) (*Certificate, error) {
|
||||
|
||||
resp := &Certificate{}
|
||||
|
||||
err := c.rancherClient.doAction(CERTIFICATE_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CertificateClient) ActionRemove(resource *Certificate) (*Certificate, error) {
|
||||
|
||||
resp := &Certificate{}
|
||||
|
||||
err := c.rancherClient.doAction(CERTIFICATE_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CertificateClient) ActionUpdate(resource *Certificate) (*Certificate, error) {
|
||||
|
||||
resp := &Certificate{}
|
||||
|
||||
err := c.rancherClient.doAction(CERTIFICATE_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CHANGE_SECRET_INPUT_TYPE = "changeSecretInput"
|
||||
)
|
||||
|
||||
type ChangeSecretInput struct {
|
||||
Resource
|
||||
|
||||
NewSecret string `json:"newSecret,omitempty" yaml:"new_secret,omitempty"`
|
||||
|
||||
OldSecret string `json:"oldSecret,omitempty" yaml:"old_secret,omitempty"`
|
||||
}
|
||||
|
||||
type ChangeSecretInputCollection struct {
|
||||
Collection
|
||||
Data []ChangeSecretInput `json:"data,omitempty"`
|
||||
client *ChangeSecretInputClient
|
||||
}
|
||||
|
||||
type ChangeSecretInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ChangeSecretInputOperations interface {
|
||||
List(opts *ListOpts) (*ChangeSecretInputCollection, error)
|
||||
Create(opts *ChangeSecretInput) (*ChangeSecretInput, error)
|
||||
Update(existing *ChangeSecretInput, updates interface{}) (*ChangeSecretInput, error)
|
||||
ById(id string) (*ChangeSecretInput, error)
|
||||
Delete(container *ChangeSecretInput) error
|
||||
}
|
||||
|
||||
func newChangeSecretInputClient(rancherClient *RancherClient) *ChangeSecretInputClient {
|
||||
return &ChangeSecretInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ChangeSecretInputClient) Create(container *ChangeSecretInput) (*ChangeSecretInput, error) {
|
||||
resp := &ChangeSecretInput{}
|
||||
err := c.rancherClient.doCreate(CHANGE_SECRET_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ChangeSecretInputClient) Update(existing *ChangeSecretInput, updates interface{}) (*ChangeSecretInput, error) {
|
||||
resp := &ChangeSecretInput{}
|
||||
err := c.rancherClient.doUpdate(CHANGE_SECRET_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ChangeSecretInputClient) List(opts *ListOpts) (*ChangeSecretInputCollection, error) {
|
||||
resp := &ChangeSecretInputCollection{}
|
||||
err := c.rancherClient.doList(CHANGE_SECRET_INPUT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ChangeSecretInputCollection) Next() (*ChangeSecretInputCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ChangeSecretInputCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ChangeSecretInputClient) ById(id string) (*ChangeSecretInput, error) {
|
||||
resp := &ChangeSecretInput{}
|
||||
err := c.rancherClient.doById(CHANGE_SECRET_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ChangeSecretInputClient) Delete(container *ChangeSecretInput) error {
|
||||
return c.rancherClient.doResourceDelete(CHANGE_SECRET_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-353
@@ -1,353 +0,0 @@
|
||||
package client
|
||||
|
||||
type RancherClient struct {
|
||||
RancherBaseClient
|
||||
|
||||
Account AccountOperations
|
||||
ActiveSetting ActiveSettingOperations
|
||||
AddOutputsInput AddOutputsInputOperations
|
||||
AddRemoveServiceLinkInput AddRemoveServiceLinkInputOperations
|
||||
Agent AgentOperations
|
||||
Amazonec2Config Amazonec2ConfigOperations
|
||||
ApiKey ApiKeyOperations
|
||||
AuditLog AuditLogOperations
|
||||
AzureConfig AzureConfigOperations
|
||||
Azureadconfig AzureadconfigOperations
|
||||
Backup BackupOperations
|
||||
BackupTarget BackupTargetOperations
|
||||
BaseMachineConfig BaseMachineConfigOperations
|
||||
Binding BindingOperations
|
||||
BlkioDeviceOption BlkioDeviceOptionOperations
|
||||
CatalogTemplate CatalogTemplateOperations
|
||||
Certificate CertificateOperations
|
||||
ChangeSecretInput ChangeSecretInputOperations
|
||||
ClusterMembership ClusterMembershipOperations
|
||||
ComposeConfig ComposeConfigOperations
|
||||
ComposeConfigInput ComposeConfigInputOperations
|
||||
ComposeProject ComposeProjectOperations
|
||||
ComposeService ComposeServiceOperations
|
||||
ConfigItem ConfigItemOperations
|
||||
ConfigItemStatus ConfigItemStatusOperations
|
||||
Container ContainerOperations
|
||||
ContainerEvent ContainerEventOperations
|
||||
ContainerExec ContainerExecOperations
|
||||
ContainerLogs ContainerLogsOperations
|
||||
ContainerProxy ContainerProxyOperations
|
||||
Credential CredentialOperations
|
||||
Databasechangelog DatabasechangelogOperations
|
||||
Databasechangeloglock DatabasechangeloglockOperations
|
||||
DefaultNetwork DefaultNetworkOperations
|
||||
DigitaloceanConfig DigitaloceanConfigOperations
|
||||
DnsService DnsServiceOperations
|
||||
DockerBuild DockerBuildOperations
|
||||
ExtensionImplementation ExtensionImplementationOperations
|
||||
ExtensionPoint ExtensionPointOperations
|
||||
ExternalDnsEvent ExternalDnsEventOperations
|
||||
ExternalEvent ExternalEventOperations
|
||||
ExternalHandler ExternalHandlerOperations
|
||||
ExternalHandlerExternalHandlerProcessMap ExternalHandlerExternalHandlerProcessMapOperations
|
||||
ExternalHandlerProcess ExternalHandlerProcessOperations
|
||||
ExternalHandlerProcessConfig ExternalHandlerProcessConfigOperations
|
||||
ExternalHostEvent ExternalHostEventOperations
|
||||
ExternalService ExternalServiceOperations
|
||||
ExternalServiceEvent ExternalServiceEventOperations
|
||||
ExternalStoragePoolEvent ExternalStoragePoolEventOperations
|
||||
ExternalVolumeEvent ExternalVolumeEventOperations
|
||||
FieldDocumentation FieldDocumentationOperations
|
||||
GenericObject GenericObjectOperations
|
||||
HaConfig HaConfigOperations
|
||||
HaConfigInput HaConfigInputOperations
|
||||
HealthcheckInstanceHostMap HealthcheckInstanceHostMapOperations
|
||||
Host HostOperations
|
||||
HostAccess HostAccessOperations
|
||||
HostApiProxyToken HostApiProxyTokenOperations
|
||||
HostTemplate HostTemplateOperations
|
||||
Identity IdentityOperations
|
||||
Image ImageOperations
|
||||
InServiceUpgradeStrategy InServiceUpgradeStrategyOperations
|
||||
Instance InstanceOperations
|
||||
InstanceConsole InstanceConsoleOperations
|
||||
InstanceConsoleInput InstanceConsoleInputOperations
|
||||
InstanceHealthCheck InstanceHealthCheckOperations
|
||||
InstanceLink InstanceLinkOperations
|
||||
InstanceStop InstanceStopOperations
|
||||
IpAddress IpAddressOperations
|
||||
KubernetesService KubernetesServiceOperations
|
||||
KubernetesStack KubernetesStackOperations
|
||||
KubernetesStackUpgrade KubernetesStackUpgradeOperations
|
||||
Label LabelOperations
|
||||
LaunchConfig LaunchConfigOperations
|
||||
LbConfig LbConfigOperations
|
||||
LbTargetConfig LbTargetConfigOperations
|
||||
LoadBalancerCookieStickinessPolicy LoadBalancerCookieStickinessPolicyOperations
|
||||
LoadBalancerService LoadBalancerServiceOperations
|
||||
LocalAuthConfig LocalAuthConfigOperations
|
||||
LogConfig LogConfigOperations
|
||||
Machine MachineOperations
|
||||
MachineDriver MachineDriverOperations
|
||||
Mount MountOperations
|
||||
MountEntry MountEntryOperations
|
||||
Network NetworkOperations
|
||||
NetworkDriver NetworkDriverOperations
|
||||
NetworkDriverService NetworkDriverServiceOperations
|
||||
NetworkPolicyRule NetworkPolicyRuleOperations
|
||||
NetworkPolicyRuleBetween NetworkPolicyRuleBetweenOperations
|
||||
NetworkPolicyRuleMember NetworkPolicyRuleMemberOperations
|
||||
NetworkPolicyRuleWithin NetworkPolicyRuleWithinOperations
|
||||
NfsConfig NfsConfigOperations
|
||||
Openldapconfig OpenldapconfigOperations
|
||||
PacketConfig PacketConfigOperations
|
||||
Password PasswordOperations
|
||||
PhysicalHost PhysicalHostOperations
|
||||
Port PortOperations
|
||||
PortRule PortRuleOperations
|
||||
ProcessDefinition ProcessDefinitionOperations
|
||||
ProcessExecution ProcessExecutionOperations
|
||||
ProcessInstance ProcessInstanceOperations
|
||||
ProcessPool ProcessPoolOperations
|
||||
ProcessSummary ProcessSummaryOperations
|
||||
Project ProjectOperations
|
||||
ProjectMember ProjectMemberOperations
|
||||
ProjectTemplate ProjectTemplateOperations
|
||||
PublicEndpoint PublicEndpointOperations
|
||||
Publish PublishOperations
|
||||
PullTask PullTaskOperations
|
||||
RecreateOnQuorumStrategyConfig RecreateOnQuorumStrategyConfigOperations
|
||||
Register RegisterOperations
|
||||
RegistrationToken RegistrationTokenOperations
|
||||
Registry RegistryOperations
|
||||
RegistryCredential RegistryCredentialOperations
|
||||
ResourceDefinition ResourceDefinitionOperations
|
||||
RestartPolicy RestartPolicyOperations
|
||||
RestoreFromBackupInput RestoreFromBackupInputOperations
|
||||
RevertToSnapshotInput RevertToSnapshotInputOperations
|
||||
RollingRestartStrategy RollingRestartStrategyOperations
|
||||
ScalePolicy ScalePolicyOperations
|
||||
ScheduledUpgrade ScheduledUpgradeOperations
|
||||
SecondaryLaunchConfig SecondaryLaunchConfigOperations
|
||||
Secret SecretOperations
|
||||
SecretReference SecretReferenceOperations
|
||||
Service ServiceOperations
|
||||
ServiceBinding ServiceBindingOperations
|
||||
ServiceConsumeMap ServiceConsumeMapOperations
|
||||
ServiceEvent ServiceEventOperations
|
||||
ServiceExposeMap ServiceExposeMapOperations
|
||||
ServiceLink ServiceLinkOperations
|
||||
ServiceLog ServiceLogOperations
|
||||
ServiceProxy ServiceProxyOperations
|
||||
ServiceRestart ServiceRestartOperations
|
||||
ServiceUpgrade ServiceUpgradeOperations
|
||||
ServiceUpgradeStrategy ServiceUpgradeStrategyOperations
|
||||
ServicesPortRange ServicesPortRangeOperations
|
||||
SetProjectMembersInput SetProjectMembersInputOperations
|
||||
SetServiceLinksInput SetServiceLinksInputOperations
|
||||
Setting SettingOperations
|
||||
Snapshot SnapshotOperations
|
||||
SnapshotBackupInput SnapshotBackupInputOperations
|
||||
Stack StackOperations
|
||||
StackUpgrade StackUpgradeOperations
|
||||
StateTransition StateTransitionOperations
|
||||
StatsAccess StatsAccessOperations
|
||||
StorageDriver StorageDriverOperations
|
||||
StorageDriverService StorageDriverServiceOperations
|
||||
StoragePool StoragePoolOperations
|
||||
Subnet SubnetOperations
|
||||
TargetPortRule TargetPortRuleOperations
|
||||
Task TaskOperations
|
||||
TaskInstance TaskInstanceOperations
|
||||
ToServiceUpgradeStrategy ToServiceUpgradeStrategyOperations
|
||||
TypeDocumentation TypeDocumentationOperations
|
||||
Ulimit UlimitOperations
|
||||
UserPreference UserPreferenceOperations
|
||||
VirtualMachine VirtualMachineOperations
|
||||
VirtualMachineDisk VirtualMachineDiskOperations
|
||||
Volume VolumeOperations
|
||||
VolumeActivateInput VolumeActivateInputOperations
|
||||
VolumeSnapshotInput VolumeSnapshotInputOperations
|
||||
VolumeTemplate VolumeTemplateOperations
|
||||
}
|
||||
|
||||
func constructClient(rancherBaseClient *RancherBaseClientImpl) *RancherClient {
|
||||
client := &RancherClient{
|
||||
RancherBaseClient: rancherBaseClient,
|
||||
}
|
||||
|
||||
client.Account = newAccountClient(client)
|
||||
client.ActiveSetting = newActiveSettingClient(client)
|
||||
client.AddOutputsInput = newAddOutputsInputClient(client)
|
||||
client.AddRemoveServiceLinkInput = newAddRemoveServiceLinkInputClient(client)
|
||||
client.Agent = newAgentClient(client)
|
||||
client.Amazonec2Config = newAmazonec2ConfigClient(client)
|
||||
client.ApiKey = newApiKeyClient(client)
|
||||
client.AuditLog = newAuditLogClient(client)
|
||||
client.AzureConfig = newAzureConfigClient(client)
|
||||
client.Azureadconfig = newAzureadconfigClient(client)
|
||||
client.Backup = newBackupClient(client)
|
||||
client.BackupTarget = newBackupTargetClient(client)
|
||||
client.BaseMachineConfig = newBaseMachineConfigClient(client)
|
||||
client.Binding = newBindingClient(client)
|
||||
client.BlkioDeviceOption = newBlkioDeviceOptionClient(client)
|
||||
client.CatalogTemplate = newCatalogTemplateClient(client)
|
||||
client.Certificate = newCertificateClient(client)
|
||||
client.ChangeSecretInput = newChangeSecretInputClient(client)
|
||||
client.ClusterMembership = newClusterMembershipClient(client)
|
||||
client.ComposeConfig = newComposeConfigClient(client)
|
||||
client.ComposeConfigInput = newComposeConfigInputClient(client)
|
||||
client.ComposeProject = newComposeProjectClient(client)
|
||||
client.ComposeService = newComposeServiceClient(client)
|
||||
client.ConfigItem = newConfigItemClient(client)
|
||||
client.ConfigItemStatus = newConfigItemStatusClient(client)
|
||||
client.Container = newContainerClient(client)
|
||||
client.ContainerEvent = newContainerEventClient(client)
|
||||
client.ContainerExec = newContainerExecClient(client)
|
||||
client.ContainerLogs = newContainerLogsClient(client)
|
||||
client.ContainerProxy = newContainerProxyClient(client)
|
||||
client.Credential = newCredentialClient(client)
|
||||
client.Databasechangelog = newDatabasechangelogClient(client)
|
||||
client.Databasechangeloglock = newDatabasechangeloglockClient(client)
|
||||
client.DefaultNetwork = newDefaultNetworkClient(client)
|
||||
client.DigitaloceanConfig = newDigitaloceanConfigClient(client)
|
||||
client.DnsService = newDnsServiceClient(client)
|
||||
client.DockerBuild = newDockerBuildClient(client)
|
||||
client.ExtensionImplementation = newExtensionImplementationClient(client)
|
||||
client.ExtensionPoint = newExtensionPointClient(client)
|
||||
client.ExternalDnsEvent = newExternalDnsEventClient(client)
|
||||
client.ExternalEvent = newExternalEventClient(client)
|
||||
client.ExternalHandler = newExternalHandlerClient(client)
|
||||
client.ExternalHandlerExternalHandlerProcessMap = newExternalHandlerExternalHandlerProcessMapClient(client)
|
||||
client.ExternalHandlerProcess = newExternalHandlerProcessClient(client)
|
||||
client.ExternalHandlerProcessConfig = newExternalHandlerProcessConfigClient(client)
|
||||
client.ExternalHostEvent = newExternalHostEventClient(client)
|
||||
client.ExternalService = newExternalServiceClient(client)
|
||||
client.ExternalServiceEvent = newExternalServiceEventClient(client)
|
||||
client.ExternalStoragePoolEvent = newExternalStoragePoolEventClient(client)
|
||||
client.ExternalVolumeEvent = newExternalVolumeEventClient(client)
|
||||
client.FieldDocumentation = newFieldDocumentationClient(client)
|
||||
client.GenericObject = newGenericObjectClient(client)
|
||||
client.HaConfig = newHaConfigClient(client)
|
||||
client.HaConfigInput = newHaConfigInputClient(client)
|
||||
client.HealthcheckInstanceHostMap = newHealthcheckInstanceHostMapClient(client)
|
||||
client.Host = newHostClient(client)
|
||||
client.HostAccess = newHostAccessClient(client)
|
||||
client.HostApiProxyToken = newHostApiProxyTokenClient(client)
|
||||
client.HostTemplate = newHostTemplateClient(client)
|
||||
client.Identity = newIdentityClient(client)
|
||||
client.Image = newImageClient(client)
|
||||
client.InServiceUpgradeStrategy = newInServiceUpgradeStrategyClient(client)
|
||||
client.Instance = newInstanceClient(client)
|
||||
client.InstanceConsole = newInstanceConsoleClient(client)
|
||||
client.InstanceConsoleInput = newInstanceConsoleInputClient(client)
|
||||
client.InstanceHealthCheck = newInstanceHealthCheckClient(client)
|
||||
client.InstanceLink = newInstanceLinkClient(client)
|
||||
client.InstanceStop = newInstanceStopClient(client)
|
||||
client.IpAddress = newIpAddressClient(client)
|
||||
client.KubernetesService = newKubernetesServiceClient(client)
|
||||
client.KubernetesStack = newKubernetesStackClient(client)
|
||||
client.KubernetesStackUpgrade = newKubernetesStackUpgradeClient(client)
|
||||
client.Label = newLabelClient(client)
|
||||
client.LaunchConfig = newLaunchConfigClient(client)
|
||||
client.LbConfig = newLbConfigClient(client)
|
||||
client.LbTargetConfig = newLbTargetConfigClient(client)
|
||||
client.LoadBalancerCookieStickinessPolicy = newLoadBalancerCookieStickinessPolicyClient(client)
|
||||
client.LoadBalancerService = newLoadBalancerServiceClient(client)
|
||||
client.LocalAuthConfig = newLocalAuthConfigClient(client)
|
||||
client.LogConfig = newLogConfigClient(client)
|
||||
client.Machine = newMachineClient(client)
|
||||
client.MachineDriver = newMachineDriverClient(client)
|
||||
client.Mount = newMountClient(client)
|
||||
client.MountEntry = newMountEntryClient(client)
|
||||
client.Network = newNetworkClient(client)
|
||||
client.NetworkDriver = newNetworkDriverClient(client)
|
||||
client.NetworkDriverService = newNetworkDriverServiceClient(client)
|
||||
client.NetworkPolicyRule = newNetworkPolicyRuleClient(client)
|
||||
client.NetworkPolicyRuleBetween = newNetworkPolicyRuleBetweenClient(client)
|
||||
client.NetworkPolicyRuleMember = newNetworkPolicyRuleMemberClient(client)
|
||||
client.NetworkPolicyRuleWithin = newNetworkPolicyRuleWithinClient(client)
|
||||
client.NfsConfig = newNfsConfigClient(client)
|
||||
client.Openldapconfig = newOpenldapconfigClient(client)
|
||||
client.PacketConfig = newPacketConfigClient(client)
|
||||
client.Password = newPasswordClient(client)
|
||||
client.PhysicalHost = newPhysicalHostClient(client)
|
||||
client.Port = newPortClient(client)
|
||||
client.PortRule = newPortRuleClient(client)
|
||||
client.ProcessDefinition = newProcessDefinitionClient(client)
|
||||
client.ProcessExecution = newProcessExecutionClient(client)
|
||||
client.ProcessInstance = newProcessInstanceClient(client)
|
||||
client.ProcessPool = newProcessPoolClient(client)
|
||||
client.ProcessSummary = newProcessSummaryClient(client)
|
||||
client.Project = newProjectClient(client)
|
||||
client.ProjectMember = newProjectMemberClient(client)
|
||||
client.ProjectTemplate = newProjectTemplateClient(client)
|
||||
client.PublicEndpoint = newPublicEndpointClient(client)
|
||||
client.Publish = newPublishClient(client)
|
||||
client.PullTask = newPullTaskClient(client)
|
||||
client.RecreateOnQuorumStrategyConfig = newRecreateOnQuorumStrategyConfigClient(client)
|
||||
client.Register = newRegisterClient(client)
|
||||
client.RegistrationToken = newRegistrationTokenClient(client)
|
||||
client.Registry = newRegistryClient(client)
|
||||
client.RegistryCredential = newRegistryCredentialClient(client)
|
||||
client.ResourceDefinition = newResourceDefinitionClient(client)
|
||||
client.RestartPolicy = newRestartPolicyClient(client)
|
||||
client.RestoreFromBackupInput = newRestoreFromBackupInputClient(client)
|
||||
client.RevertToSnapshotInput = newRevertToSnapshotInputClient(client)
|
||||
client.RollingRestartStrategy = newRollingRestartStrategyClient(client)
|
||||
client.ScalePolicy = newScalePolicyClient(client)
|
||||
client.ScheduledUpgrade = newScheduledUpgradeClient(client)
|
||||
client.SecondaryLaunchConfig = newSecondaryLaunchConfigClient(client)
|
||||
client.Secret = newSecretClient(client)
|
||||
client.SecretReference = newSecretReferenceClient(client)
|
||||
client.Service = newServiceClient(client)
|
||||
client.ServiceBinding = newServiceBindingClient(client)
|
||||
client.ServiceConsumeMap = newServiceConsumeMapClient(client)
|
||||
client.ServiceEvent = newServiceEventClient(client)
|
||||
client.ServiceExposeMap = newServiceExposeMapClient(client)
|
||||
client.ServiceLink = newServiceLinkClient(client)
|
||||
client.ServiceLog = newServiceLogClient(client)
|
||||
client.ServiceProxy = newServiceProxyClient(client)
|
||||
client.ServiceRestart = newServiceRestartClient(client)
|
||||
client.ServiceUpgrade = newServiceUpgradeClient(client)
|
||||
client.ServiceUpgradeStrategy = newServiceUpgradeStrategyClient(client)
|
||||
client.ServicesPortRange = newServicesPortRangeClient(client)
|
||||
client.SetProjectMembersInput = newSetProjectMembersInputClient(client)
|
||||
client.SetServiceLinksInput = newSetServiceLinksInputClient(client)
|
||||
client.Setting = newSettingClient(client)
|
||||
client.Snapshot = newSnapshotClient(client)
|
||||
client.SnapshotBackupInput = newSnapshotBackupInputClient(client)
|
||||
client.Stack = newStackClient(client)
|
||||
client.StackUpgrade = newStackUpgradeClient(client)
|
||||
client.StateTransition = newStateTransitionClient(client)
|
||||
client.StatsAccess = newStatsAccessClient(client)
|
||||
client.StorageDriver = newStorageDriverClient(client)
|
||||
client.StorageDriverService = newStorageDriverServiceClient(client)
|
||||
client.StoragePool = newStoragePoolClient(client)
|
||||
client.Subnet = newSubnetClient(client)
|
||||
client.TargetPortRule = newTargetPortRuleClient(client)
|
||||
client.Task = newTaskClient(client)
|
||||
client.TaskInstance = newTaskInstanceClient(client)
|
||||
client.ToServiceUpgradeStrategy = newToServiceUpgradeStrategyClient(client)
|
||||
client.TypeDocumentation = newTypeDocumentationClient(client)
|
||||
client.Ulimit = newUlimitClient(client)
|
||||
client.UserPreference = newUserPreferenceClient(client)
|
||||
client.VirtualMachine = newVirtualMachineClient(client)
|
||||
client.VirtualMachineDisk = newVirtualMachineDiskClient(client)
|
||||
client.Volume = newVolumeClient(client)
|
||||
client.VolumeActivateInput = newVolumeActivateInputClient(client)
|
||||
client.VolumeSnapshotInput = newVolumeSnapshotInputClient(client)
|
||||
client.VolumeTemplate = newVolumeTemplateClient(client)
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
func NewRancherClient(opts *ClientOpts) (*RancherClient, error) {
|
||||
rancherBaseClient := &RancherBaseClientImpl{
|
||||
Types: map[string]Schema{},
|
||||
}
|
||||
client := constructClient(rancherBaseClient)
|
||||
|
||||
err := setupRancherBaseClient(rancherBaseClient, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CLUSTER_MEMBERSHIP_TYPE = "clusterMembership"
|
||||
)
|
||||
|
||||
type ClusterMembership struct {
|
||||
Resource
|
||||
|
||||
Clustered bool `json:"clustered,omitempty" yaml:"clustered,omitempty"`
|
||||
|
||||
Config string `json:"config,omitempty" yaml:"config,omitempty"`
|
||||
|
||||
Heartbeat int64 `json:"heartbeat,omitempty" yaml:"heartbeat,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterMembershipCollection struct {
|
||||
Collection
|
||||
Data []ClusterMembership `json:"data,omitempty"`
|
||||
client *ClusterMembershipClient
|
||||
}
|
||||
|
||||
type ClusterMembershipClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ClusterMembershipOperations interface {
|
||||
List(opts *ListOpts) (*ClusterMembershipCollection, error)
|
||||
Create(opts *ClusterMembership) (*ClusterMembership, error)
|
||||
Update(existing *ClusterMembership, updates interface{}) (*ClusterMembership, error)
|
||||
ById(id string) (*ClusterMembership, error)
|
||||
Delete(container *ClusterMembership) error
|
||||
}
|
||||
|
||||
func newClusterMembershipClient(rancherClient *RancherClient) *ClusterMembershipClient {
|
||||
return &ClusterMembershipClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ClusterMembershipClient) Create(container *ClusterMembership) (*ClusterMembership, error) {
|
||||
resp := &ClusterMembership{}
|
||||
err := c.rancherClient.doCreate(CLUSTER_MEMBERSHIP_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterMembershipClient) Update(existing *ClusterMembership, updates interface{}) (*ClusterMembership, error) {
|
||||
resp := &ClusterMembership{}
|
||||
err := c.rancherClient.doUpdate(CLUSTER_MEMBERSHIP_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterMembershipClient) List(opts *ListOpts) (*ClusterMembershipCollection, error) {
|
||||
resp := &ClusterMembershipCollection{}
|
||||
err := c.rancherClient.doList(CLUSTER_MEMBERSHIP_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ClusterMembershipCollection) Next() (*ClusterMembershipCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ClusterMembershipCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ClusterMembershipClient) ById(id string) (*ClusterMembership, error) {
|
||||
resp := &ClusterMembership{}
|
||||
err := c.rancherClient.doById(CLUSTER_MEMBERSHIP_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterMembershipClient) Delete(container *ClusterMembership) error {
|
||||
return c.rancherClient.doResourceDelete(CLUSTER_MEMBERSHIP_TYPE, &container.Resource)
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
COMPOSE_CONFIG_TYPE = "composeConfig"
|
||||
)
|
||||
|
||||
type ComposeConfig struct {
|
||||
Resource
|
||||
|
||||
DockerComposeConfig string `json:"dockerComposeConfig,omitempty" yaml:"docker_compose_config,omitempty"`
|
||||
|
||||
RancherComposeConfig string `json:"rancherComposeConfig,omitempty" yaml:"rancher_compose_config,omitempty"`
|
||||
}
|
||||
|
||||
type ComposeConfigCollection struct {
|
||||
Collection
|
||||
Data []ComposeConfig `json:"data,omitempty"`
|
||||
client *ComposeConfigClient
|
||||
}
|
||||
|
||||
type ComposeConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ComposeConfigOperations interface {
|
||||
List(opts *ListOpts) (*ComposeConfigCollection, error)
|
||||
Create(opts *ComposeConfig) (*ComposeConfig, error)
|
||||
Update(existing *ComposeConfig, updates interface{}) (*ComposeConfig, error)
|
||||
ById(id string) (*ComposeConfig, error)
|
||||
Delete(container *ComposeConfig) error
|
||||
}
|
||||
|
||||
func newComposeConfigClient(rancherClient *RancherClient) *ComposeConfigClient {
|
||||
return &ComposeConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ComposeConfigClient) Create(container *ComposeConfig) (*ComposeConfig, error) {
|
||||
resp := &ComposeConfig{}
|
||||
err := c.rancherClient.doCreate(COMPOSE_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeConfigClient) Update(existing *ComposeConfig, updates interface{}) (*ComposeConfig, error) {
|
||||
resp := &ComposeConfig{}
|
||||
err := c.rancherClient.doUpdate(COMPOSE_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeConfigClient) List(opts *ListOpts) (*ComposeConfigCollection, error) {
|
||||
resp := &ComposeConfigCollection{}
|
||||
err := c.rancherClient.doList(COMPOSE_CONFIG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ComposeConfigCollection) Next() (*ComposeConfigCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ComposeConfigCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ComposeConfigClient) ById(id string) (*ComposeConfig, error) {
|
||||
resp := &ComposeConfig{}
|
||||
err := c.rancherClient.doById(COMPOSE_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeConfigClient) Delete(container *ComposeConfig) error {
|
||||
return c.rancherClient.doResourceDelete(COMPOSE_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
COMPOSE_CONFIG_INPUT_TYPE = "composeConfigInput"
|
||||
)
|
||||
|
||||
type ComposeConfigInput struct {
|
||||
Resource
|
||||
|
||||
ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"`
|
||||
}
|
||||
|
||||
type ComposeConfigInputCollection struct {
|
||||
Collection
|
||||
Data []ComposeConfigInput `json:"data,omitempty"`
|
||||
client *ComposeConfigInputClient
|
||||
}
|
||||
|
||||
type ComposeConfigInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ComposeConfigInputOperations interface {
|
||||
List(opts *ListOpts) (*ComposeConfigInputCollection, error)
|
||||
Create(opts *ComposeConfigInput) (*ComposeConfigInput, error)
|
||||
Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error)
|
||||
ById(id string) (*ComposeConfigInput, error)
|
||||
Delete(container *ComposeConfigInput) error
|
||||
}
|
||||
|
||||
func newComposeConfigInputClient(rancherClient *RancherClient) *ComposeConfigInputClient {
|
||||
return &ComposeConfigInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ComposeConfigInputClient) Create(container *ComposeConfigInput) (*ComposeConfigInput, error) {
|
||||
resp := &ComposeConfigInput{}
|
||||
err := c.rancherClient.doCreate(COMPOSE_CONFIG_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeConfigInputClient) Update(existing *ComposeConfigInput, updates interface{}) (*ComposeConfigInput, error) {
|
||||
resp := &ComposeConfigInput{}
|
||||
err := c.rancherClient.doUpdate(COMPOSE_CONFIG_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeConfigInputClient) List(opts *ListOpts) (*ComposeConfigInputCollection, error) {
|
||||
resp := &ComposeConfigInputCollection{}
|
||||
err := c.rancherClient.doList(COMPOSE_CONFIG_INPUT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ComposeConfigInputCollection) Next() (*ComposeConfigInputCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ComposeConfigInputCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ComposeConfigInputClient) ById(id string) (*ComposeConfigInput, error) {
|
||||
resp := &ComposeConfigInput{}
|
||||
err := c.rancherClient.doById(COMPOSE_CONFIG_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeConfigInputClient) Delete(container *ComposeConfigInput) error {
|
||||
return c.rancherClient.doResourceDelete(COMPOSE_CONFIG_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-191
@@ -1,191 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
COMPOSE_PROJECT_TYPE = "composeProject"
|
||||
)
|
||||
|
||||
type ComposeProject struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Answers map[string]interface{} `json:"answers,omitempty" yaml:"answers,omitempty"`
|
||||
|
||||
Binding *Binding `json:"binding,omitempty" yaml:"binding,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
Group string `json:"group,omitempty" yaml:"group,omitempty"`
|
||||
|
||||
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
PreviousEnvironment map[string]interface{} `json:"previousEnvironment,omitempty" yaml:"previous_environment,omitempty"`
|
||||
|
||||
PreviousExternalId string `json:"previousExternalId,omitempty" yaml:"previous_external_id,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
System bool `json:"system,omitempty" yaml:"system,omitempty"`
|
||||
|
||||
Templates map[string]interface{} `json:"templates,omitempty" yaml:"templates,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ComposeProjectCollection struct {
|
||||
Collection
|
||||
Data []ComposeProject `json:"data,omitempty"`
|
||||
client *ComposeProjectClient
|
||||
}
|
||||
|
||||
type ComposeProjectClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ComposeProjectOperations interface {
|
||||
List(opts *ListOpts) (*ComposeProjectCollection, error)
|
||||
Create(opts *ComposeProject) (*ComposeProject, error)
|
||||
Update(existing *ComposeProject, updates interface{}) (*ComposeProject, error)
|
||||
ById(id string) (*ComposeProject, error)
|
||||
Delete(container *ComposeProject) error
|
||||
|
||||
ActionCancelupgrade(*ComposeProject) (*Stack, error)
|
||||
|
||||
ActionCreate(*ComposeProject) (*Stack, error)
|
||||
|
||||
ActionError(*ComposeProject) (*Stack, error)
|
||||
|
||||
ActionFinishupgrade(*ComposeProject) (*Stack, error)
|
||||
|
||||
ActionRemove(*ComposeProject) (*Stack, error)
|
||||
|
||||
ActionRollback(*ComposeProject) (*Stack, error)
|
||||
}
|
||||
|
||||
func newComposeProjectClient(rancherClient *RancherClient) *ComposeProjectClient {
|
||||
return &ComposeProjectClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) Create(container *ComposeProject) (*ComposeProject, error) {
|
||||
resp := &ComposeProject{}
|
||||
err := c.rancherClient.doCreate(COMPOSE_PROJECT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) Update(existing *ComposeProject, updates interface{}) (*ComposeProject, error) {
|
||||
resp := &ComposeProject{}
|
||||
err := c.rancherClient.doUpdate(COMPOSE_PROJECT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) List(opts *ListOpts) (*ComposeProjectCollection, error) {
|
||||
resp := &ComposeProjectCollection{}
|
||||
err := c.rancherClient.doList(COMPOSE_PROJECT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ComposeProjectCollection) Next() (*ComposeProjectCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ComposeProjectCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) ById(id string) (*ComposeProject, error) {
|
||||
resp := &ComposeProject{}
|
||||
err := c.rancherClient.doById(COMPOSE_PROJECT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) Delete(container *ComposeProject) error {
|
||||
return c.rancherClient.doResourceDelete(COMPOSE_PROJECT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) ActionCancelupgrade(resource *ComposeProject) (*Stack, error) {
|
||||
|
||||
resp := &Stack{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) ActionCreate(resource *ComposeProject) (*Stack, error) {
|
||||
|
||||
resp := &Stack{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) ActionError(resource *ComposeProject) (*Stack, error) {
|
||||
|
||||
resp := &Stack{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "error", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) ActionFinishupgrade(resource *ComposeProject) (*Stack, error) {
|
||||
|
||||
resp := &Stack{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "finishupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) ActionRemove(resource *ComposeProject) (*Stack, error) {
|
||||
|
||||
resp := &Stack{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeProjectClient) ActionRollback(resource *ComposeProject) (*Stack, error) {
|
||||
|
||||
resp := &Stack{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_PROJECT_TYPE, "rollback", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-212
@@ -1,212 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
COMPOSE_SERVICE_TYPE = "composeService"
|
||||
)
|
||||
|
||||
type ComposeService struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
CurrentScale int64 `json:"currentScale,omitempty" yaml:"current_scale,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"`
|
||||
|
||||
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
|
||||
|
||||
InstanceIds []string `json:"instanceIds,omitempty" yaml:"instance_ids,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"`
|
||||
|
||||
LinkedServices map[string]interface{} `json:"linkedServices,omitempty" yaml:"linked_services,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
PublicEndpoints []PublicEndpoint `json:"publicEndpoints,omitempty" yaml:"public_endpoints,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
Scale int64 `json:"scale,omitempty" yaml:"scale,omitempty"`
|
||||
|
||||
ScalePolicy *ScalePolicy `json:"scalePolicy,omitempty" yaml:"scale_policy,omitempty"`
|
||||
|
||||
SelectorContainer string `json:"selectorContainer,omitempty" yaml:"selector_container,omitempty"`
|
||||
|
||||
SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"`
|
||||
|
||||
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
|
||||
|
||||
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
System bool `json:"system,omitempty" yaml:"system,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
|
||||
Vip string `json:"vip,omitempty" yaml:"vip,omitempty"`
|
||||
}
|
||||
|
||||
type ComposeServiceCollection struct {
|
||||
Collection
|
||||
Data []ComposeService `json:"data,omitempty"`
|
||||
client *ComposeServiceClient
|
||||
}
|
||||
|
||||
type ComposeServiceClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ComposeServiceOperations interface {
|
||||
List(opts *ListOpts) (*ComposeServiceCollection, error)
|
||||
Create(opts *ComposeService) (*ComposeService, error)
|
||||
Update(existing *ComposeService, updates interface{}) (*ComposeService, error)
|
||||
ById(id string) (*ComposeService, error)
|
||||
Delete(container *ComposeService) error
|
||||
|
||||
ActionActivate(*ComposeService) (*Service, error)
|
||||
|
||||
ActionCancelupgrade(*ComposeService) (*Service, error)
|
||||
|
||||
ActionContinueupgrade(*ComposeService) (*Service, error)
|
||||
|
||||
ActionCreate(*ComposeService) (*Service, error)
|
||||
|
||||
ActionFinishupgrade(*ComposeService) (*Service, error)
|
||||
|
||||
ActionRemove(*ComposeService) (*Service, error)
|
||||
|
||||
ActionRollback(*ComposeService) (*Service, error)
|
||||
}
|
||||
|
||||
func newComposeServiceClient(rancherClient *RancherClient) *ComposeServiceClient {
|
||||
return &ComposeServiceClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) Create(container *ComposeService) (*ComposeService, error) {
|
||||
resp := &ComposeService{}
|
||||
err := c.rancherClient.doCreate(COMPOSE_SERVICE_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) Update(existing *ComposeService, updates interface{}) (*ComposeService, error) {
|
||||
resp := &ComposeService{}
|
||||
err := c.rancherClient.doUpdate(COMPOSE_SERVICE_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) List(opts *ListOpts) (*ComposeServiceCollection, error) {
|
||||
resp := &ComposeServiceCollection{}
|
||||
err := c.rancherClient.doList(COMPOSE_SERVICE_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ComposeServiceCollection) Next() (*ComposeServiceCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ComposeServiceCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ById(id string) (*ComposeService, error) {
|
||||
resp := &ComposeService{}
|
||||
err := c.rancherClient.doById(COMPOSE_SERVICE_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) Delete(container *ComposeService) error {
|
||||
return c.rancherClient.doResourceDelete(COMPOSE_SERVICE_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ActionActivate(resource *ComposeService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ActionCancelupgrade(resource *ComposeService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ActionContinueupgrade(resource *ComposeService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "continueupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ActionCreate(resource *ComposeService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ActionFinishupgrade(resource *ComposeService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ActionRemove(resource *ComposeService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ComposeServiceClient) ActionRollback(resource *ComposeService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(COMPOSE_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CONFIG_ITEM_TYPE = "configItem"
|
||||
)
|
||||
|
||||
type ConfigItem struct {
|
||||
Resource
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
SourceVersion string `json:"sourceVersion,omitempty" yaml:"source_version,omitempty"`
|
||||
}
|
||||
|
||||
type ConfigItemCollection struct {
|
||||
Collection
|
||||
Data []ConfigItem `json:"data,omitempty"`
|
||||
client *ConfigItemClient
|
||||
}
|
||||
|
||||
type ConfigItemClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ConfigItemOperations interface {
|
||||
List(opts *ListOpts) (*ConfigItemCollection, error)
|
||||
Create(opts *ConfigItem) (*ConfigItem, error)
|
||||
Update(existing *ConfigItem, updates interface{}) (*ConfigItem, error)
|
||||
ById(id string) (*ConfigItem, error)
|
||||
Delete(container *ConfigItem) error
|
||||
}
|
||||
|
||||
func newConfigItemClient(rancherClient *RancherClient) *ConfigItemClient {
|
||||
return &ConfigItemClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ConfigItemClient) Create(container *ConfigItem) (*ConfigItem, error) {
|
||||
resp := &ConfigItem{}
|
||||
err := c.rancherClient.doCreate(CONFIG_ITEM_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ConfigItemClient) Update(existing *ConfigItem, updates interface{}) (*ConfigItem, error) {
|
||||
resp := &ConfigItem{}
|
||||
err := c.rancherClient.doUpdate(CONFIG_ITEM_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ConfigItemClient) List(opts *ListOpts) (*ConfigItemCollection, error) {
|
||||
resp := &ConfigItemCollection{}
|
||||
err := c.rancherClient.doList(CONFIG_ITEM_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ConfigItemCollection) Next() (*ConfigItemCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ConfigItemCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ConfigItemClient) ById(id string) (*ConfigItem, error) {
|
||||
resp := &ConfigItem{}
|
||||
err := c.rancherClient.doById(CONFIG_ITEM_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ConfigItemClient) Delete(container *ConfigItem) error {
|
||||
return c.rancherClient.doResourceDelete(CONFIG_ITEM_TYPE, &container.Resource)
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CONFIG_ITEM_STATUS_TYPE = "configItemStatus"
|
||||
)
|
||||
|
||||
type ConfigItemStatus struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
|
||||
|
||||
AppliedUpdated string `json:"appliedUpdated,omitempty" yaml:"applied_updated,omitempty"`
|
||||
|
||||
AppliedVersion int64 `json:"appliedVersion,omitempty" yaml:"applied_version,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RequestedUpdated string `json:"requestedUpdated,omitempty" yaml:"requested_updated,omitempty"`
|
||||
|
||||
RequestedVersion int64 `json:"requestedVersion,omitempty" yaml:"requested_version,omitempty"`
|
||||
|
||||
SourceVersion string `json:"sourceVersion,omitempty" yaml:"source_version,omitempty"`
|
||||
}
|
||||
|
||||
type ConfigItemStatusCollection struct {
|
||||
Collection
|
||||
Data []ConfigItemStatus `json:"data,omitempty"`
|
||||
client *ConfigItemStatusClient
|
||||
}
|
||||
|
||||
type ConfigItemStatusClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ConfigItemStatusOperations interface {
|
||||
List(opts *ListOpts) (*ConfigItemStatusCollection, error)
|
||||
Create(opts *ConfigItemStatus) (*ConfigItemStatus, error)
|
||||
Update(existing *ConfigItemStatus, updates interface{}) (*ConfigItemStatus, error)
|
||||
ById(id string) (*ConfigItemStatus, error)
|
||||
Delete(container *ConfigItemStatus) error
|
||||
}
|
||||
|
||||
func newConfigItemStatusClient(rancherClient *RancherClient) *ConfigItemStatusClient {
|
||||
return &ConfigItemStatusClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ConfigItemStatusClient) Create(container *ConfigItemStatus) (*ConfigItemStatus, error) {
|
||||
resp := &ConfigItemStatus{}
|
||||
err := c.rancherClient.doCreate(CONFIG_ITEM_STATUS_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ConfigItemStatusClient) Update(existing *ConfigItemStatus, updates interface{}) (*ConfigItemStatus, error) {
|
||||
resp := &ConfigItemStatus{}
|
||||
err := c.rancherClient.doUpdate(CONFIG_ITEM_STATUS_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ConfigItemStatusClient) List(opts *ListOpts) (*ConfigItemStatusCollection, error) {
|
||||
resp := &ConfigItemStatusCollection{}
|
||||
err := c.rancherClient.doList(CONFIG_ITEM_STATUS_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ConfigItemStatusCollection) Next() (*ConfigItemStatusCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ConfigItemStatusCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ConfigItemStatusClient) ById(id string) (*ConfigItemStatus, error) {
|
||||
resp := &ConfigItemStatus{}
|
||||
err := c.rancherClient.doById(CONFIG_ITEM_STATUS_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ConfigItemStatusClient) Delete(container *ConfigItemStatus) error {
|
||||
return c.rancherClient.doResourceDelete(CONFIG_ITEM_STATUS_TYPE, &container.Resource)
|
||||
}
|
||||
-517
@@ -1,517 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CONTAINER_TYPE = "container"
|
||||
)
|
||||
|
||||
type Container struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
|
||||
|
||||
AllocationState string `json:"allocationState,omitempty" yaml:"allocation_state,omitempty"`
|
||||
|
||||
BlkioDeviceOptions map[string]interface{} `json:"blkioDeviceOptions,omitempty" yaml:"blkio_device_options,omitempty"`
|
||||
|
||||
BlkioWeight int64 `json:"blkioWeight,omitempty" yaml:"blkio_weight,omitempty"`
|
||||
|
||||
Build *DockerBuild `json:"build,omitempty" yaml:"build,omitempty"`
|
||||
|
||||
CapAdd []string `json:"capAdd,omitempty" yaml:"cap_add,omitempty"`
|
||||
|
||||
CapDrop []string `json:"capDrop,omitempty" yaml:"cap_drop,omitempty"`
|
||||
|
||||
CgroupParent string `json:"cgroupParent,omitempty" yaml:"cgroup_parent,omitempty"`
|
||||
|
||||
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
|
||||
|
||||
Count int64 `json:"count,omitempty" yaml:"count,omitempty"`
|
||||
|
||||
CpuCount int64 `json:"cpuCount,omitempty" yaml:"cpu_count,omitempty"`
|
||||
|
||||
CpuPercent int64 `json:"cpuPercent,omitempty" yaml:"cpu_percent,omitempty"`
|
||||
|
||||
CpuPeriod int64 `json:"cpuPeriod,omitempty" yaml:"cpu_period,omitempty"`
|
||||
|
||||
CpuQuota int64 `json:"cpuQuota,omitempty" yaml:"cpu_quota,omitempty"`
|
||||
|
||||
CpuRealtimePeriod int64 `json:"cpuRealtimePeriod,omitempty" yaml:"cpu_realtime_period,omitempty"`
|
||||
|
||||
CpuRealtimeRuntime int64 `json:"cpuRealtimeRuntime,omitempty" yaml:"cpu_realtime_runtime,omitempty"`
|
||||
|
||||
CpuSet string `json:"cpuSet,omitempty" yaml:"cpu_set,omitempty"`
|
||||
|
||||
CpuSetMems string `json:"cpuSetMems,omitempty" yaml:"cpu_set_mems,omitempty"`
|
||||
|
||||
CpuShares int64 `json:"cpuShares,omitempty" yaml:"cpu_shares,omitempty"`
|
||||
|
||||
CreateIndex int64 `json:"createIndex,omitempty" yaml:"create_index,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
DataVolumeMounts map[string]interface{} `json:"dataVolumeMounts,omitempty" yaml:"data_volume_mounts,omitempty"`
|
||||
|
||||
DataVolumes []string `json:"dataVolumes,omitempty" yaml:"data_volumes,omitempty"`
|
||||
|
||||
DataVolumesFrom []string `json:"dataVolumesFrom,omitempty" yaml:"data_volumes_from,omitempty"`
|
||||
|
||||
DeploymentUnitUuid string `json:"deploymentUnitUuid,omitempty" yaml:"deployment_unit_uuid,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Devices []string `json:"devices,omitempty" yaml:"devices,omitempty"`
|
||||
|
||||
DiskQuota int64 `json:"diskQuota,omitempty" yaml:"disk_quota,omitempty"`
|
||||
|
||||
Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"`
|
||||
|
||||
DnsOpt []string `json:"dnsOpt,omitempty" yaml:"dns_opt,omitempty"`
|
||||
|
||||
DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"`
|
||||
|
||||
DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"`
|
||||
|
||||
EntryPoint []string `json:"entryPoint,omitempty" yaml:"entry_point,omitempty"`
|
||||
|
||||
Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
|
||||
|
||||
Expose []string `json:"expose,omitempty" yaml:"expose,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
ExtraHosts []string `json:"extraHosts,omitempty" yaml:"extra_hosts,omitempty"`
|
||||
|
||||
FirstRunning string `json:"firstRunning,omitempty" yaml:"first_running,omitempty"`
|
||||
|
||||
GroupAdd []string `json:"groupAdd,omitempty" yaml:"group_add,omitempty"`
|
||||
|
||||
HealthCheck *InstanceHealthCheck `json:"healthCheck,omitempty" yaml:"health_check,omitempty"`
|
||||
|
||||
HealthCmd []string `json:"healthCmd,omitempty" yaml:"health_cmd,omitempty"`
|
||||
|
||||
HealthInterval int64 `json:"healthInterval,omitempty" yaml:"health_interval,omitempty"`
|
||||
|
||||
HealthRetries int64 `json:"healthRetries,omitempty" yaml:"health_retries,omitempty"`
|
||||
|
||||
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
|
||||
|
||||
HealthTimeout int64 `json:"healthTimeout,omitempty" yaml:"health_timeout,omitempty"`
|
||||
|
||||
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
|
||||
|
||||
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
|
||||
|
||||
ImageUuid string `json:"imageUuid,omitempty" yaml:"image_uuid,omitempty"`
|
||||
|
||||
InstanceLinks map[string]interface{} `json:"instanceLinks,omitempty" yaml:"instance_links,omitempty"`
|
||||
|
||||
InstanceTriggeredStop string `json:"instanceTriggeredStop,omitempty" yaml:"instance_triggered_stop,omitempty"`
|
||||
|
||||
IoMaximumBandwidth int64 `json:"ioMaximumBandwidth,omitempty" yaml:"io_maximum_bandwidth,omitempty"`
|
||||
|
||||
IoMaximumIOps int64 `json:"ioMaximumIOps,omitempty" yaml:"io_maximum_iops,omitempty"`
|
||||
|
||||
Ip string `json:"ip,omitempty" yaml:"ip,omitempty"`
|
||||
|
||||
Ip6 string `json:"ip6,omitempty" yaml:"ip6,omitempty"`
|
||||
|
||||
IpcMode string `json:"ipcMode,omitempty" yaml:"ipc_mode,omitempty"`
|
||||
|
||||
Isolation string `json:"isolation,omitempty" yaml:"isolation,omitempty"`
|
||||
|
||||
KernelMemory int64 `json:"kernelMemory,omitempty" yaml:"kernel_memory,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
|
||||
LogConfig *LogConfig `json:"logConfig,omitempty" yaml:"log_config,omitempty"`
|
||||
|
||||
LxcConf map[string]interface{} `json:"lxcConf,omitempty" yaml:"lxc_conf,omitempty"`
|
||||
|
||||
Memory int64 `json:"memory,omitempty" yaml:"memory,omitempty"`
|
||||
|
||||
MemoryReservation int64 `json:"memoryReservation,omitempty" yaml:"memory_reservation,omitempty"`
|
||||
|
||||
MemorySwap int64 `json:"memorySwap,omitempty" yaml:"memory_swap,omitempty"`
|
||||
|
||||
MemorySwappiness int64 `json:"memorySwappiness,omitempty" yaml:"memory_swappiness,omitempty"`
|
||||
|
||||
MilliCpuReservation int64 `json:"milliCpuReservation,omitempty" yaml:"milli_cpu_reservation,omitempty"`
|
||||
|
||||
Mounts []MountEntry `json:"mounts,omitempty" yaml:"mounts,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
NativeContainer bool `json:"nativeContainer,omitempty" yaml:"native_container,omitempty"`
|
||||
|
||||
NetAlias []string `json:"netAlias,omitempty" yaml:"net_alias,omitempty"`
|
||||
|
||||
NetworkContainerId string `json:"networkContainerId,omitempty" yaml:"network_container_id,omitempty"`
|
||||
|
||||
NetworkIds []string `json:"networkIds,omitempty" yaml:"network_ids,omitempty"`
|
||||
|
||||
NetworkMode string `json:"networkMode,omitempty" yaml:"network_mode,omitempty"`
|
||||
|
||||
OomKillDisable bool `json:"oomKillDisable,omitempty" yaml:"oom_kill_disable,omitempty"`
|
||||
|
||||
OomScoreAdj int64 `json:"oomScoreAdj,omitempty" yaml:"oom_score_adj,omitempty"`
|
||||
|
||||
PidMode string `json:"pidMode,omitempty" yaml:"pid_mode,omitempty"`
|
||||
|
||||
PidsLimit int64 `json:"pidsLimit,omitempty" yaml:"pids_limit,omitempty"`
|
||||
|
||||
Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"`
|
||||
|
||||
PrimaryIpAddress string `json:"primaryIpAddress,omitempty" yaml:"primary_ip_address,omitempty"`
|
||||
|
||||
PrimaryNetworkId string `json:"primaryNetworkId,omitempty" yaml:"primary_network_id,omitempty"`
|
||||
|
||||
Privileged bool `json:"privileged,omitempty" yaml:"privileged,omitempty"`
|
||||
|
||||
PublishAllPorts bool `json:"publishAllPorts,omitempty" yaml:"publish_all_ports,omitempty"`
|
||||
|
||||
ReadOnly bool `json:"readOnly,omitempty" yaml:"read_only,omitempty"`
|
||||
|
||||
RegistryCredentialId string `json:"registryCredentialId,omitempty" yaml:"registry_credential_id,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
RequestedHostId string `json:"requestedHostId,omitempty" yaml:"requested_host_id,omitempty"`
|
||||
|
||||
RestartPolicy *RestartPolicy `json:"restartPolicy,omitempty" yaml:"restart_policy,omitempty"`
|
||||
|
||||
RunInit bool `json:"runInit,omitempty" yaml:"run_init,omitempty"`
|
||||
|
||||
Secrets []SecretReference `json:"secrets,omitempty" yaml:"secrets,omitempty"`
|
||||
|
||||
SecurityOpt []string `json:"securityOpt,omitempty" yaml:"security_opt,omitempty"`
|
||||
|
||||
ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"`
|
||||
|
||||
ServiceIds []string `json:"serviceIds,omitempty" yaml:"service_ids,omitempty"`
|
||||
|
||||
ShmSize int64 `json:"shmSize,omitempty" yaml:"shm_size,omitempty"`
|
||||
|
||||
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
|
||||
|
||||
StartCount int64 `json:"startCount,omitempty" yaml:"start_count,omitempty"`
|
||||
|
||||
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
StdinOpen bool `json:"stdinOpen,omitempty" yaml:"stdin_open,omitempty"`
|
||||
|
||||
StopSignal string `json:"stopSignal,omitempty" yaml:"stop_signal,omitempty"`
|
||||
|
||||
StopTimeout int64 `json:"stopTimeout,omitempty" yaml:"stop_timeout,omitempty"`
|
||||
|
||||
StorageOpt map[string]interface{} `json:"storageOpt,omitempty" yaml:"storage_opt,omitempty"`
|
||||
|
||||
Sysctls map[string]interface{} `json:"sysctls,omitempty" yaml:"sysctls,omitempty"`
|
||||
|
||||
System bool `json:"system,omitempty" yaml:"system,omitempty"`
|
||||
|
||||
Tmpfs map[string]interface{} `json:"tmpfs,omitempty" yaml:"tmpfs,omitempty"`
|
||||
|
||||
Token string `json:"token,omitempty" yaml:"token,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"`
|
||||
|
||||
Ulimits []Ulimit `json:"ulimits,omitempty" yaml:"ulimits,omitempty"`
|
||||
|
||||
User string `json:"user,omitempty" yaml:"user,omitempty"`
|
||||
|
||||
UserPorts []string `json:"userPorts,omitempty" yaml:"user_ports,omitempty"`
|
||||
|
||||
UsernsMode string `json:"usernsMode,omitempty" yaml:"userns_mode,omitempty"`
|
||||
|
||||
Uts string `json:"uts,omitempty" yaml:"uts,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
|
||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
||||
|
||||
VolumeDriver string `json:"volumeDriver,omitempty" yaml:"volume_driver,omitempty"`
|
||||
|
||||
WorkingDir string `json:"workingDir,omitempty" yaml:"working_dir,omitempty"`
|
||||
}
|
||||
|
||||
type ContainerCollection struct {
|
||||
Collection
|
||||
Data []Container `json:"data,omitempty"`
|
||||
client *ContainerClient
|
||||
}
|
||||
|
||||
type ContainerClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ContainerOperations interface {
|
||||
List(opts *ListOpts) (*ContainerCollection, error)
|
||||
Create(opts *Container) (*Container, error)
|
||||
Update(existing *Container, updates interface{}) (*Container, error)
|
||||
ById(id string) (*Container, error)
|
||||
Delete(container *Container) error
|
||||
|
||||
ActionAllocate(*Container) (*Instance, error)
|
||||
|
||||
ActionConsole(*Container, *InstanceConsoleInput) (*InstanceConsole, error)
|
||||
|
||||
ActionCreate(*Container) (*Instance, error)
|
||||
|
||||
ActionDeallocate(*Container) (*Instance, error)
|
||||
|
||||
ActionError(*Container) (*Instance, error)
|
||||
|
||||
ActionExecute(*Container, *ContainerExec) (*HostAccess, error)
|
||||
|
||||
ActionLogs(*Container, *ContainerLogs) (*HostAccess, error)
|
||||
|
||||
ActionMigrate(*Container) (*Instance, error)
|
||||
|
||||
ActionProxy(*Container, *ContainerProxy) (*HostAccess, error)
|
||||
|
||||
ActionPurge(*Container) (*Instance, error)
|
||||
|
||||
ActionRemove(*Container) (*Instance, error)
|
||||
|
||||
ActionRestart(*Container) (*Instance, error)
|
||||
|
||||
ActionStart(*Container) (*Instance, error)
|
||||
|
||||
ActionStop(*Container, *InstanceStop) (*Instance, error)
|
||||
|
||||
ActionUpdate(*Container) (*Instance, error)
|
||||
|
||||
ActionUpdatehealthy(*Container) (*Instance, error)
|
||||
|
||||
ActionUpdatereinitializing(*Container) (*Instance, error)
|
||||
|
||||
ActionUpdateunhealthy(*Container) (*Instance, error)
|
||||
}
|
||||
|
||||
func newContainerClient(rancherClient *RancherClient) *ContainerClient {
|
||||
return &ContainerClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ContainerClient) Create(container *Container) (*Container, error) {
|
||||
resp := &Container{}
|
||||
err := c.rancherClient.doCreate(CONTAINER_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) Update(existing *Container, updates interface{}) (*Container, error) {
|
||||
resp := &Container{}
|
||||
err := c.rancherClient.doUpdate(CONTAINER_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) List(opts *ListOpts) (*ContainerCollection, error) {
|
||||
resp := &ContainerCollection{}
|
||||
err := c.rancherClient.doList(CONTAINER_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ContainerCollection) Next() (*ContainerCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ContainerCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ById(id string) (*Container, error) {
|
||||
resp := &Container{}
|
||||
err := c.rancherClient.doById(CONTAINER_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) Delete(container *Container) error {
|
||||
return c.rancherClient.doResourceDelete(CONTAINER_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionAllocate(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "allocate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionConsole(resource *Container, input *InstanceConsoleInput) (*InstanceConsole, error) {
|
||||
|
||||
resp := &InstanceConsole{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "console", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionCreate(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionDeallocate(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "deallocate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionError(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "error", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionExecute(resource *Container, input *ContainerExec) (*HostAccess, error) {
|
||||
|
||||
resp := &HostAccess{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "execute", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionLogs(resource *Container, input *ContainerLogs) (*HostAccess, error) {
|
||||
|
||||
resp := &HostAccess{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "logs", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionMigrate(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "migrate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionProxy(resource *Container, input *ContainerProxy) (*HostAccess, error) {
|
||||
|
||||
resp := &HostAccess{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "proxy", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionPurge(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionRemove(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionRestart(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "restart", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionStart(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "start", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionStop(resource *Container, input *InstanceStop) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "stop", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionUpdate(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionUpdatehealthy(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "updatehealthy", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionUpdatereinitializing(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "updatereinitializing", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerClient) ActionUpdateunhealthy(resource *Container) (*Instance, error) {
|
||||
|
||||
resp := &Instance{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_TYPE, "updateunhealthy", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-129
@@ -1,129 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CONTAINER_EVENT_TYPE = "containerEvent"
|
||||
)
|
||||
|
||||
type ContainerEvent struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
DockerInspect interface{} `json:"dockerInspect,omitempty" yaml:"docker_inspect,omitempty"`
|
||||
|
||||
ExternalFrom string `json:"externalFrom,omitempty" yaml:"external_from,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
ExternalStatus string `json:"externalStatus,omitempty" yaml:"external_status,omitempty"`
|
||||
|
||||
ExternalTimestamp int64 `json:"externalTimestamp,omitempty" yaml:"external_timestamp,omitempty"`
|
||||
|
||||
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
ReportedHostUuid string `json:"reportedHostUuid,omitempty" yaml:"reported_host_uuid,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
}
|
||||
|
||||
type ContainerEventCollection struct {
|
||||
Collection
|
||||
Data []ContainerEvent `json:"data,omitempty"`
|
||||
client *ContainerEventClient
|
||||
}
|
||||
|
||||
type ContainerEventClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ContainerEventOperations interface {
|
||||
List(opts *ListOpts) (*ContainerEventCollection, error)
|
||||
Create(opts *ContainerEvent) (*ContainerEvent, error)
|
||||
Update(existing *ContainerEvent, updates interface{}) (*ContainerEvent, error)
|
||||
ById(id string) (*ContainerEvent, error)
|
||||
Delete(container *ContainerEvent) error
|
||||
|
||||
ActionCreate(*ContainerEvent) (*ContainerEvent, error)
|
||||
|
||||
ActionRemove(*ContainerEvent) (*ContainerEvent, error)
|
||||
}
|
||||
|
||||
func newContainerEventClient(rancherClient *RancherClient) *ContainerEventClient {
|
||||
return &ContainerEventClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ContainerEventClient) Create(container *ContainerEvent) (*ContainerEvent, error) {
|
||||
resp := &ContainerEvent{}
|
||||
err := c.rancherClient.doCreate(CONTAINER_EVENT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerEventClient) Update(existing *ContainerEvent, updates interface{}) (*ContainerEvent, error) {
|
||||
resp := &ContainerEvent{}
|
||||
err := c.rancherClient.doUpdate(CONTAINER_EVENT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerEventClient) List(opts *ListOpts) (*ContainerEventCollection, error) {
|
||||
resp := &ContainerEventCollection{}
|
||||
err := c.rancherClient.doList(CONTAINER_EVENT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ContainerEventCollection) Next() (*ContainerEventCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ContainerEventCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ContainerEventClient) ById(id string) (*ContainerEvent, error) {
|
||||
resp := &ContainerEvent{}
|
||||
err := c.rancherClient.doById(CONTAINER_EVENT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerEventClient) Delete(container *ContainerEvent) error {
|
||||
return c.rancherClient.doResourceDelete(CONTAINER_EVENT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ContainerEventClient) ActionCreate(resource *ContainerEvent) (*ContainerEvent, error) {
|
||||
|
||||
resp := &ContainerEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_EVENT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerEventClient) ActionRemove(resource *ContainerEvent) (*ContainerEvent, error) {
|
||||
|
||||
resp := &ContainerEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(CONTAINER_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-85
@@ -1,85 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CONTAINER_EXEC_TYPE = "containerExec"
|
||||
)
|
||||
|
||||
type ContainerExec struct {
|
||||
Resource
|
||||
|
||||
AttachStdin bool `json:"attachStdin,omitempty" yaml:"attach_stdin,omitempty"`
|
||||
|
||||
AttachStdout bool `json:"attachStdout,omitempty" yaml:"attach_stdout,omitempty"`
|
||||
|
||||
Command []string `json:"command,omitempty" yaml:"command,omitempty"`
|
||||
|
||||
Tty bool `json:"tty,omitempty" yaml:"tty,omitempty"`
|
||||
}
|
||||
|
||||
type ContainerExecCollection struct {
|
||||
Collection
|
||||
Data []ContainerExec `json:"data,omitempty"`
|
||||
client *ContainerExecClient
|
||||
}
|
||||
|
||||
type ContainerExecClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ContainerExecOperations interface {
|
||||
List(opts *ListOpts) (*ContainerExecCollection, error)
|
||||
Create(opts *ContainerExec) (*ContainerExec, error)
|
||||
Update(existing *ContainerExec, updates interface{}) (*ContainerExec, error)
|
||||
ById(id string) (*ContainerExec, error)
|
||||
Delete(container *ContainerExec) error
|
||||
}
|
||||
|
||||
func newContainerExecClient(rancherClient *RancherClient) *ContainerExecClient {
|
||||
return &ContainerExecClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ContainerExecClient) Create(container *ContainerExec) (*ContainerExec, error) {
|
||||
resp := &ContainerExec{}
|
||||
err := c.rancherClient.doCreate(CONTAINER_EXEC_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerExecClient) Update(existing *ContainerExec, updates interface{}) (*ContainerExec, error) {
|
||||
resp := &ContainerExec{}
|
||||
err := c.rancherClient.doUpdate(CONTAINER_EXEC_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerExecClient) List(opts *ListOpts) (*ContainerExecCollection, error) {
|
||||
resp := &ContainerExecCollection{}
|
||||
err := c.rancherClient.doList(CONTAINER_EXEC_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ContainerExecCollection) Next() (*ContainerExecCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ContainerExecCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ContainerExecClient) ById(id string) (*ContainerExec, error) {
|
||||
resp := &ContainerExec{}
|
||||
err := c.rancherClient.doById(CONTAINER_EXEC_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerExecClient) Delete(container *ContainerExec) error {
|
||||
return c.rancherClient.doResourceDelete(CONTAINER_EXEC_TYPE, &container.Resource)
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CONTAINER_LOGS_TYPE = "containerLogs"
|
||||
)
|
||||
|
||||
type ContainerLogs struct {
|
||||
Resource
|
||||
|
||||
Follow bool `json:"follow,omitempty" yaml:"follow,omitempty"`
|
||||
|
||||
Lines int64 `json:"lines,omitempty" yaml:"lines,omitempty"`
|
||||
}
|
||||
|
||||
type ContainerLogsCollection struct {
|
||||
Collection
|
||||
Data []ContainerLogs `json:"data,omitempty"`
|
||||
client *ContainerLogsClient
|
||||
}
|
||||
|
||||
type ContainerLogsClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ContainerLogsOperations interface {
|
||||
List(opts *ListOpts) (*ContainerLogsCollection, error)
|
||||
Create(opts *ContainerLogs) (*ContainerLogs, error)
|
||||
Update(existing *ContainerLogs, updates interface{}) (*ContainerLogs, error)
|
||||
ById(id string) (*ContainerLogs, error)
|
||||
Delete(container *ContainerLogs) error
|
||||
}
|
||||
|
||||
func newContainerLogsClient(rancherClient *RancherClient) *ContainerLogsClient {
|
||||
return &ContainerLogsClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ContainerLogsClient) Create(container *ContainerLogs) (*ContainerLogs, error) {
|
||||
resp := &ContainerLogs{}
|
||||
err := c.rancherClient.doCreate(CONTAINER_LOGS_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerLogsClient) Update(existing *ContainerLogs, updates interface{}) (*ContainerLogs, error) {
|
||||
resp := &ContainerLogs{}
|
||||
err := c.rancherClient.doUpdate(CONTAINER_LOGS_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerLogsClient) List(opts *ListOpts) (*ContainerLogsCollection, error) {
|
||||
resp := &ContainerLogsCollection{}
|
||||
err := c.rancherClient.doList(CONTAINER_LOGS_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ContainerLogsCollection) Next() (*ContainerLogsCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ContainerLogsCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ContainerLogsClient) ById(id string) (*ContainerLogs, error) {
|
||||
resp := &ContainerLogs{}
|
||||
err := c.rancherClient.doById(CONTAINER_LOGS_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerLogsClient) Delete(container *ContainerLogs) error {
|
||||
return c.rancherClient.doResourceDelete(CONTAINER_LOGS_TYPE, &container.Resource)
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CONTAINER_PROXY_TYPE = "containerProxy"
|
||||
)
|
||||
|
||||
type ContainerProxy struct {
|
||||
Resource
|
||||
|
||||
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
|
||||
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
|
||||
}
|
||||
|
||||
type ContainerProxyCollection struct {
|
||||
Collection
|
||||
Data []ContainerProxy `json:"data,omitempty"`
|
||||
client *ContainerProxyClient
|
||||
}
|
||||
|
||||
type ContainerProxyClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ContainerProxyOperations interface {
|
||||
List(opts *ListOpts) (*ContainerProxyCollection, error)
|
||||
Create(opts *ContainerProxy) (*ContainerProxy, error)
|
||||
Update(existing *ContainerProxy, updates interface{}) (*ContainerProxy, error)
|
||||
ById(id string) (*ContainerProxy, error)
|
||||
Delete(container *ContainerProxy) error
|
||||
}
|
||||
|
||||
func newContainerProxyClient(rancherClient *RancherClient) *ContainerProxyClient {
|
||||
return &ContainerProxyClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ContainerProxyClient) Create(container *ContainerProxy) (*ContainerProxy, error) {
|
||||
resp := &ContainerProxy{}
|
||||
err := c.rancherClient.doCreate(CONTAINER_PROXY_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerProxyClient) Update(existing *ContainerProxy, updates interface{}) (*ContainerProxy, error) {
|
||||
resp := &ContainerProxy{}
|
||||
err := c.rancherClient.doUpdate(CONTAINER_PROXY_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerProxyClient) List(opts *ListOpts) (*ContainerProxyCollection, error) {
|
||||
resp := &ContainerProxyCollection{}
|
||||
err := c.rancherClient.doList(CONTAINER_PROXY_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ContainerProxyCollection) Next() (*ContainerProxyCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ContainerProxyCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ContainerProxyClient) ById(id string) (*ContainerProxy, error) {
|
||||
resp := &ContainerProxy{}
|
||||
err := c.rancherClient.doById(CONTAINER_PROXY_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ContainerProxyClient) Delete(container *ContainerProxy) error {
|
||||
return c.rancherClient.doResourceDelete(CONTAINER_PROXY_TYPE, &container.Resource)
|
||||
}
|
||||
-173
@@ -1,173 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CREDENTIAL_TYPE = "credential"
|
||||
)
|
||||
|
||||
type Credential struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
PublicValue string `json:"publicValue,omitempty" yaml:"public_value,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
SecretValue string `json:"secretValue,omitempty" yaml:"secret_value,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type CredentialCollection struct {
|
||||
Collection
|
||||
Data []Credential `json:"data,omitempty"`
|
||||
client *CredentialClient
|
||||
}
|
||||
|
||||
type CredentialClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type CredentialOperations interface {
|
||||
List(opts *ListOpts) (*CredentialCollection, error)
|
||||
Create(opts *Credential) (*Credential, error)
|
||||
Update(existing *Credential, updates interface{}) (*Credential, error)
|
||||
ById(id string) (*Credential, error)
|
||||
Delete(container *Credential) error
|
||||
|
||||
ActionActivate(*Credential) (*Credential, error)
|
||||
|
||||
ActionCreate(*Credential) (*Credential, error)
|
||||
|
||||
ActionDeactivate(*Credential) (*Credential, error)
|
||||
|
||||
ActionPurge(*Credential) (*Credential, error)
|
||||
|
||||
ActionRemove(*Credential) (*Credential, error)
|
||||
|
||||
ActionUpdate(*Credential) (*Credential, error)
|
||||
}
|
||||
|
||||
func newCredentialClient(rancherClient *RancherClient) *CredentialClient {
|
||||
return &CredentialClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CredentialClient) Create(container *Credential) (*Credential, error) {
|
||||
resp := &Credential{}
|
||||
err := c.rancherClient.doCreate(CREDENTIAL_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) Update(existing *Credential, updates interface{}) (*Credential, error) {
|
||||
resp := &Credential{}
|
||||
err := c.rancherClient.doUpdate(CREDENTIAL_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) List(opts *ListOpts) (*CredentialCollection, error) {
|
||||
resp := &CredentialCollection{}
|
||||
err := c.rancherClient.doList(CREDENTIAL_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *CredentialCollection) Next() (*CredentialCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &CredentialCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *CredentialClient) ById(id string) (*Credential, error) {
|
||||
resp := &Credential{}
|
||||
err := c.rancherClient.doById(CREDENTIAL_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) Delete(container *Credential) error {
|
||||
return c.rancherClient.doResourceDelete(CREDENTIAL_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *CredentialClient) ActionActivate(resource *Credential) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) ActionCreate(resource *Credential) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) ActionDeactivate(resource *Credential) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) ActionPurge(resource *Credential) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) ActionRemove(resource *Credential) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *CredentialClient) ActionUpdate(resource *Credential) (*Credential, error) {
|
||||
|
||||
resp := &Credential{}
|
||||
|
||||
err := c.rancherClient.doAction(CREDENTIAL_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
DATABASECHANGELOG_TYPE = "databasechangelog"
|
||||
)
|
||||
|
||||
type Databasechangelog struct {
|
||||
Resource
|
||||
|
||||
Author string `json:"author,omitempty" yaml:"author,omitempty"`
|
||||
|
||||
Comments string `json:"comments,omitempty" yaml:"comments,omitempty"`
|
||||
|
||||
Dateexecuted string `json:"dateexecuted,omitempty" yaml:"dateexecuted,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Exectype string `json:"exectype,omitempty" yaml:"exectype,omitempty"`
|
||||
|
||||
Filename string `json:"filename,omitempty" yaml:"filename,omitempty"`
|
||||
|
||||
Liquibase string `json:"liquibase,omitempty" yaml:"liquibase,omitempty"`
|
||||
|
||||
Md5sum string `json:"md5sum,omitempty" yaml:"md5sum,omitempty"`
|
||||
|
||||
Orderexecuted int64 `json:"orderexecuted,omitempty" yaml:"orderexecuted,omitempty"`
|
||||
|
||||
Tag string `json:"tag,omitempty" yaml:"tag,omitempty"`
|
||||
}
|
||||
|
||||
type DatabasechangelogCollection struct {
|
||||
Collection
|
||||
Data []Databasechangelog `json:"data,omitempty"`
|
||||
client *DatabasechangelogClient
|
||||
}
|
||||
|
||||
type DatabasechangelogClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type DatabasechangelogOperations interface {
|
||||
List(opts *ListOpts) (*DatabasechangelogCollection, error)
|
||||
Create(opts *Databasechangelog) (*Databasechangelog, error)
|
||||
Update(existing *Databasechangelog, updates interface{}) (*Databasechangelog, error)
|
||||
ById(id string) (*Databasechangelog, error)
|
||||
Delete(container *Databasechangelog) error
|
||||
}
|
||||
|
||||
func newDatabasechangelogClient(rancherClient *RancherClient) *DatabasechangelogClient {
|
||||
return &DatabasechangelogClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DatabasechangelogClient) Create(container *Databasechangelog) (*Databasechangelog, error) {
|
||||
resp := &Databasechangelog{}
|
||||
err := c.rancherClient.doCreate(DATABASECHANGELOG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DatabasechangelogClient) Update(existing *Databasechangelog, updates interface{}) (*Databasechangelog, error) {
|
||||
resp := &Databasechangelog{}
|
||||
err := c.rancherClient.doUpdate(DATABASECHANGELOG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DatabasechangelogClient) List(opts *ListOpts) (*DatabasechangelogCollection, error) {
|
||||
resp := &DatabasechangelogCollection{}
|
||||
err := c.rancherClient.doList(DATABASECHANGELOG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *DatabasechangelogCollection) Next() (*DatabasechangelogCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &DatabasechangelogCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *DatabasechangelogClient) ById(id string) (*Databasechangelog, error) {
|
||||
resp := &Databasechangelog{}
|
||||
err := c.rancherClient.doById(DATABASECHANGELOG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DatabasechangelogClient) Delete(container *Databasechangelog) error {
|
||||
return c.rancherClient.doResourceDelete(DATABASECHANGELOG_TYPE, &container.Resource)
|
||||
}
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
DATABASECHANGELOGLOCK_TYPE = "databasechangeloglock"
|
||||
)
|
||||
|
||||
type Databasechangeloglock struct {
|
||||
Resource
|
||||
|
||||
Locked bool `json:"locked,omitempty" yaml:"locked,omitempty"`
|
||||
|
||||
Lockedby string `json:"lockedby,omitempty" yaml:"lockedby,omitempty"`
|
||||
|
||||
Lockgranted string `json:"lockgranted,omitempty" yaml:"lockgranted,omitempty"`
|
||||
}
|
||||
|
||||
type DatabasechangeloglockCollection struct {
|
||||
Collection
|
||||
Data []Databasechangeloglock `json:"data,omitempty"`
|
||||
client *DatabasechangeloglockClient
|
||||
}
|
||||
|
||||
type DatabasechangeloglockClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type DatabasechangeloglockOperations interface {
|
||||
List(opts *ListOpts) (*DatabasechangeloglockCollection, error)
|
||||
Create(opts *Databasechangeloglock) (*Databasechangeloglock, error)
|
||||
Update(existing *Databasechangeloglock, updates interface{}) (*Databasechangeloglock, error)
|
||||
ById(id string) (*Databasechangeloglock, error)
|
||||
Delete(container *Databasechangeloglock) error
|
||||
}
|
||||
|
||||
func newDatabasechangeloglockClient(rancherClient *RancherClient) *DatabasechangeloglockClient {
|
||||
return &DatabasechangeloglockClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DatabasechangeloglockClient) Create(container *Databasechangeloglock) (*Databasechangeloglock, error) {
|
||||
resp := &Databasechangeloglock{}
|
||||
err := c.rancherClient.doCreate(DATABASECHANGELOGLOCK_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DatabasechangeloglockClient) Update(existing *Databasechangeloglock, updates interface{}) (*Databasechangeloglock, error) {
|
||||
resp := &Databasechangeloglock{}
|
||||
err := c.rancherClient.doUpdate(DATABASECHANGELOGLOCK_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DatabasechangeloglockClient) List(opts *ListOpts) (*DatabasechangeloglockCollection, error) {
|
||||
resp := &DatabasechangeloglockCollection{}
|
||||
err := c.rancherClient.doList(DATABASECHANGELOGLOCK_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *DatabasechangeloglockCollection) Next() (*DatabasechangeloglockCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &DatabasechangeloglockCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *DatabasechangeloglockClient) ById(id string) (*Databasechangeloglock, error) {
|
||||
resp := &Databasechangeloglock{}
|
||||
err := c.rancherClient.doById(DATABASECHANGELOGLOCK_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DatabasechangeloglockClient) Delete(container *Databasechangeloglock) error {
|
||||
return c.rancherClient.doResourceDelete(DATABASECHANGELOGLOCK_TYPE, &container.Resource)
|
||||
}
|
||||
-183
@@ -1,183 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
DEFAULT_NETWORK_TYPE = "defaultNetwork"
|
||||
)
|
||||
|
||||
type DefaultNetwork struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
DefaultPolicyAction string `json:"defaultPolicyAction,omitempty" yaml:"default_policy_action,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Dns []string `json:"dns,omitempty" yaml:"dns,omitempty"`
|
||||
|
||||
DnsSearch []string `json:"dnsSearch,omitempty" yaml:"dns_search,omitempty"`
|
||||
|
||||
HostPorts bool `json:"hostPorts,omitempty" yaml:"host_ports,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Policy []NetworkPolicyRule `json:"policy,omitempty" yaml:"policy,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Subnets []Subnet `json:"subnets,omitempty" yaml:"subnets,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type DefaultNetworkCollection struct {
|
||||
Collection
|
||||
Data []DefaultNetwork `json:"data,omitempty"`
|
||||
client *DefaultNetworkClient
|
||||
}
|
||||
|
||||
type DefaultNetworkClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type DefaultNetworkOperations interface {
|
||||
List(opts *ListOpts) (*DefaultNetworkCollection, error)
|
||||
Create(opts *DefaultNetwork) (*DefaultNetwork, error)
|
||||
Update(existing *DefaultNetwork, updates interface{}) (*DefaultNetwork, error)
|
||||
ById(id string) (*DefaultNetwork, error)
|
||||
Delete(container *DefaultNetwork) error
|
||||
|
||||
ActionActivate(*DefaultNetwork) (*Network, error)
|
||||
|
||||
ActionCreate(*DefaultNetwork) (*Network, error)
|
||||
|
||||
ActionDeactivate(*DefaultNetwork) (*Network, error)
|
||||
|
||||
ActionPurge(*DefaultNetwork) (*Network, error)
|
||||
|
||||
ActionRemove(*DefaultNetwork) (*Network, error)
|
||||
|
||||
ActionUpdate(*DefaultNetwork) (*Network, error)
|
||||
}
|
||||
|
||||
func newDefaultNetworkClient(rancherClient *RancherClient) *DefaultNetworkClient {
|
||||
return &DefaultNetworkClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) Create(container *DefaultNetwork) (*DefaultNetwork, error) {
|
||||
resp := &DefaultNetwork{}
|
||||
err := c.rancherClient.doCreate(DEFAULT_NETWORK_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) Update(existing *DefaultNetwork, updates interface{}) (*DefaultNetwork, error) {
|
||||
resp := &DefaultNetwork{}
|
||||
err := c.rancherClient.doUpdate(DEFAULT_NETWORK_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) List(opts *ListOpts) (*DefaultNetworkCollection, error) {
|
||||
resp := &DefaultNetworkCollection{}
|
||||
err := c.rancherClient.doList(DEFAULT_NETWORK_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *DefaultNetworkCollection) Next() (*DefaultNetworkCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &DefaultNetworkCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) ById(id string) (*DefaultNetwork, error) {
|
||||
resp := &DefaultNetwork{}
|
||||
err := c.rancherClient.doById(DEFAULT_NETWORK_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) Delete(container *DefaultNetwork) error {
|
||||
return c.rancherClient.doResourceDelete(DEFAULT_NETWORK_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) ActionActivate(resource *DefaultNetwork) (*Network, error) {
|
||||
|
||||
resp := &Network{}
|
||||
|
||||
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) ActionCreate(resource *DefaultNetwork) (*Network, error) {
|
||||
|
||||
resp := &Network{}
|
||||
|
||||
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) ActionDeactivate(resource *DefaultNetwork) (*Network, error) {
|
||||
|
||||
resp := &Network{}
|
||||
|
||||
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) ActionPurge(resource *DefaultNetwork) (*Network, error) {
|
||||
|
||||
resp := &Network{}
|
||||
|
||||
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) ActionRemove(resource *DefaultNetwork) (*Network, error) {
|
||||
|
||||
resp := &Network{}
|
||||
|
||||
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DefaultNetworkClient) ActionUpdate(resource *DefaultNetwork) (*Network, error) {
|
||||
|
||||
resp := &Network{}
|
||||
|
||||
err := c.rancherClient.doAction(DEFAULT_NETWORK_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
DIGITALOCEAN_CONFIG_TYPE = "digitaloceanConfig"
|
||||
)
|
||||
|
||||
type DigitaloceanConfig struct {
|
||||
Resource
|
||||
|
||||
AccessToken string `json:"accessToken,omitempty" yaml:"access_token,omitempty"`
|
||||
|
||||
Backups bool `json:"backups,omitempty" yaml:"backups,omitempty"`
|
||||
|
||||
Image string `json:"image,omitempty" yaml:"image,omitempty"`
|
||||
|
||||
Ipv6 bool `json:"ipv6,omitempty" yaml:"ipv6,omitempty"`
|
||||
|
||||
PrivateNetworking bool `json:"privateNetworking,omitempty" yaml:"private_networking,omitempty"`
|
||||
|
||||
Region string `json:"region,omitempty" yaml:"region,omitempty"`
|
||||
|
||||
Size string `json:"size,omitempty" yaml:"size,omitempty"`
|
||||
|
||||
SshKeyFingerprint string `json:"sshKeyFingerprint,omitempty" yaml:"ssh_key_fingerprint,omitempty"`
|
||||
|
||||
SshKeyPath string `json:"sshKeyPath,omitempty" yaml:"ssh_key_path,omitempty"`
|
||||
|
||||
SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"`
|
||||
|
||||
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
|
||||
|
||||
Userdata string `json:"userdata,omitempty" yaml:"userdata,omitempty"`
|
||||
}
|
||||
|
||||
type DigitaloceanConfigCollection struct {
|
||||
Collection
|
||||
Data []DigitaloceanConfig `json:"data,omitempty"`
|
||||
client *DigitaloceanConfigClient
|
||||
}
|
||||
|
||||
type DigitaloceanConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type DigitaloceanConfigOperations interface {
|
||||
List(opts *ListOpts) (*DigitaloceanConfigCollection, error)
|
||||
Create(opts *DigitaloceanConfig) (*DigitaloceanConfig, error)
|
||||
Update(existing *DigitaloceanConfig, updates interface{}) (*DigitaloceanConfig, error)
|
||||
ById(id string) (*DigitaloceanConfig, error)
|
||||
Delete(container *DigitaloceanConfig) error
|
||||
}
|
||||
|
||||
func newDigitaloceanConfigClient(rancherClient *RancherClient) *DigitaloceanConfigClient {
|
||||
return &DigitaloceanConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DigitaloceanConfigClient) Create(container *DigitaloceanConfig) (*DigitaloceanConfig, error) {
|
||||
resp := &DigitaloceanConfig{}
|
||||
err := c.rancherClient.doCreate(DIGITALOCEAN_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DigitaloceanConfigClient) Update(existing *DigitaloceanConfig, updates interface{}) (*DigitaloceanConfig, error) {
|
||||
resp := &DigitaloceanConfig{}
|
||||
err := c.rancherClient.doUpdate(DIGITALOCEAN_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DigitaloceanConfigClient) List(opts *ListOpts) (*DigitaloceanConfigCollection, error) {
|
||||
resp := &DigitaloceanConfigCollection{}
|
||||
err := c.rancherClient.doList(DIGITALOCEAN_CONFIG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *DigitaloceanConfigCollection) Next() (*DigitaloceanConfigCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &DigitaloceanConfigCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *DigitaloceanConfigClient) ById(id string) (*DigitaloceanConfig, error) {
|
||||
resp := &DigitaloceanConfig{}
|
||||
err := c.rancherClient.doById(DIGITALOCEAN_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DigitaloceanConfigClient) Delete(container *DigitaloceanConfig) error {
|
||||
return c.rancherClient.doResourceDelete(DIGITALOCEAN_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-285
@@ -1,285 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
DNS_SERVICE_TYPE = "dnsService"
|
||||
)
|
||||
|
||||
type DnsService struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
AssignServiceIpAddress bool `json:"assignServiceIpAddress,omitempty" yaml:"assign_service_ip_address,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"`
|
||||
|
||||
HealthState string `json:"healthState,omitempty" yaml:"health_state,omitempty"`
|
||||
|
||||
InstanceIds []string `json:"instanceIds,omitempty" yaml:"instance_ids,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
LaunchConfig *LaunchConfig `json:"launchConfig,omitempty" yaml:"launch_config,omitempty"`
|
||||
|
||||
LinkedServices map[string]interface{} `json:"linkedServices,omitempty" yaml:"linked_services,omitempty"`
|
||||
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
RetainIp bool `json:"retainIp,omitempty" yaml:"retain_ip,omitempty"`
|
||||
|
||||
SelectorLink string `json:"selectorLink,omitempty" yaml:"selector_link,omitempty"`
|
||||
|
||||
StackId string `json:"stackId,omitempty" yaml:"stack_id,omitempty"`
|
||||
|
||||
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
System bool `json:"system,omitempty" yaml:"system,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Upgrade *ServiceUpgrade `json:"upgrade,omitempty" yaml:"upgrade,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type DnsServiceCollection struct {
|
||||
Collection
|
||||
Data []DnsService `json:"data,omitempty"`
|
||||
client *DnsServiceClient
|
||||
}
|
||||
|
||||
type DnsServiceClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type DnsServiceOperations interface {
|
||||
List(opts *ListOpts) (*DnsServiceCollection, error)
|
||||
Create(opts *DnsService) (*DnsService, error)
|
||||
Update(existing *DnsService, updates interface{}) (*DnsService, error)
|
||||
ById(id string) (*DnsService, error)
|
||||
Delete(container *DnsService) error
|
||||
|
||||
ActionActivate(*DnsService) (*Service, error)
|
||||
|
||||
ActionAddservicelink(*DnsService, *AddRemoveServiceLinkInput) (*Service, error)
|
||||
|
||||
ActionCancelupgrade(*DnsService) (*Service, error)
|
||||
|
||||
ActionContinueupgrade(*DnsService) (*Service, error)
|
||||
|
||||
ActionCreate(*DnsService) (*Service, error)
|
||||
|
||||
ActionDeactivate(*DnsService) (*Service, error)
|
||||
|
||||
ActionFinishupgrade(*DnsService) (*Service, error)
|
||||
|
||||
ActionRemove(*DnsService) (*Service, error)
|
||||
|
||||
ActionRemoveservicelink(*DnsService, *AddRemoveServiceLinkInput) (*Service, error)
|
||||
|
||||
ActionRestart(*DnsService, *ServiceRestart) (*Service, error)
|
||||
|
||||
ActionRollback(*DnsService) (*Service, error)
|
||||
|
||||
ActionSetservicelinks(*DnsService, *SetServiceLinksInput) (*Service, error)
|
||||
|
||||
ActionUpdate(*DnsService) (*Service, error)
|
||||
|
||||
ActionUpgrade(*DnsService, *ServiceUpgrade) (*Service, error)
|
||||
}
|
||||
|
||||
func newDnsServiceClient(rancherClient *RancherClient) *DnsServiceClient {
|
||||
return &DnsServiceClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) Create(container *DnsService) (*DnsService, error) {
|
||||
resp := &DnsService{}
|
||||
err := c.rancherClient.doCreate(DNS_SERVICE_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) Update(existing *DnsService, updates interface{}) (*DnsService, error) {
|
||||
resp := &DnsService{}
|
||||
err := c.rancherClient.doUpdate(DNS_SERVICE_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) List(opts *ListOpts) (*DnsServiceCollection, error) {
|
||||
resp := &DnsServiceCollection{}
|
||||
err := c.rancherClient.doList(DNS_SERVICE_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *DnsServiceCollection) Next() (*DnsServiceCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &DnsServiceCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ById(id string) (*DnsService, error) {
|
||||
resp := &DnsService{}
|
||||
err := c.rancherClient.doById(DNS_SERVICE_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) Delete(container *DnsService) error {
|
||||
return c.rancherClient.doResourceDelete(DNS_SERVICE_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionActivate(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionAddservicelink(resource *DnsService, input *AddRemoveServiceLinkInput) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "addservicelink", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionCancelupgrade(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionContinueupgrade(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "continueupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionCreate(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionDeactivate(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionFinishupgrade(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "finishupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionRemove(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionRemoveservicelink(resource *DnsService, input *AddRemoveServiceLinkInput) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "removeservicelink", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionRestart(resource *DnsService, input *ServiceRestart) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "restart", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionRollback(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "rollback", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionSetservicelinks(resource *DnsService, input *SetServiceLinksInput) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "setservicelinks", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionUpdate(resource *DnsService) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DnsServiceClient) ActionUpgrade(resource *DnsService, input *ServiceUpgrade) (*Service, error) {
|
||||
|
||||
resp := &Service{}
|
||||
|
||||
err := c.rancherClient.doAction(DNS_SERVICE_TYPE, "upgrade", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
DOCKER_BUILD_TYPE = "dockerBuild"
|
||||
)
|
||||
|
||||
type DockerBuild struct {
|
||||
Resource
|
||||
|
||||
Context string `json:"context,omitempty" yaml:"context,omitempty"`
|
||||
|
||||
Dockerfile string `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"`
|
||||
|
||||
Forcerm bool `json:"forcerm,omitempty" yaml:"forcerm,omitempty"`
|
||||
|
||||
Nocache bool `json:"nocache,omitempty" yaml:"nocache,omitempty"`
|
||||
|
||||
Remote string `json:"remote,omitempty" yaml:"remote,omitempty"`
|
||||
|
||||
Rm bool `json:"rm,omitempty" yaml:"rm,omitempty"`
|
||||
}
|
||||
|
||||
type DockerBuildCollection struct {
|
||||
Collection
|
||||
Data []DockerBuild `json:"data,omitempty"`
|
||||
client *DockerBuildClient
|
||||
}
|
||||
|
||||
type DockerBuildClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type DockerBuildOperations interface {
|
||||
List(opts *ListOpts) (*DockerBuildCollection, error)
|
||||
Create(opts *DockerBuild) (*DockerBuild, error)
|
||||
Update(existing *DockerBuild, updates interface{}) (*DockerBuild, error)
|
||||
ById(id string) (*DockerBuild, error)
|
||||
Delete(container *DockerBuild) error
|
||||
}
|
||||
|
||||
func newDockerBuildClient(rancherClient *RancherClient) *DockerBuildClient {
|
||||
return &DockerBuildClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DockerBuildClient) Create(container *DockerBuild) (*DockerBuild, error) {
|
||||
resp := &DockerBuild{}
|
||||
err := c.rancherClient.doCreate(DOCKER_BUILD_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DockerBuildClient) Update(existing *DockerBuild, updates interface{}) (*DockerBuild, error) {
|
||||
resp := &DockerBuild{}
|
||||
err := c.rancherClient.doUpdate(DOCKER_BUILD_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DockerBuildClient) List(opts *ListOpts) (*DockerBuildCollection, error) {
|
||||
resp := &DockerBuildCollection{}
|
||||
err := c.rancherClient.doList(DOCKER_BUILD_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *DockerBuildCollection) Next() (*DockerBuildCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &DockerBuildCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *DockerBuildClient) ById(id string) (*DockerBuild, error) {
|
||||
resp := &DockerBuild{}
|
||||
err := c.rancherClient.doById(DOCKER_BUILD_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DockerBuildClient) Delete(container *DockerBuild) error {
|
||||
return c.rancherClient.doResourceDelete(DOCKER_BUILD_TYPE, &container.Resource)
|
||||
}
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTENSION_IMPLEMENTATION_TYPE = "extensionImplementation"
|
||||
)
|
||||
|
||||
type ExtensionImplementation struct {
|
||||
Resource
|
||||
|
||||
ClassName string `json:"className,omitempty" yaml:"class_name,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Properties map[string]interface{} `json:"properties,omitempty" yaml:"properties,omitempty"`
|
||||
}
|
||||
|
||||
type ExtensionImplementationCollection struct {
|
||||
Collection
|
||||
Data []ExtensionImplementation `json:"data,omitempty"`
|
||||
client *ExtensionImplementationClient
|
||||
}
|
||||
|
||||
type ExtensionImplementationClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExtensionImplementationOperations interface {
|
||||
List(opts *ListOpts) (*ExtensionImplementationCollection, error)
|
||||
Create(opts *ExtensionImplementation) (*ExtensionImplementation, error)
|
||||
Update(existing *ExtensionImplementation, updates interface{}) (*ExtensionImplementation, error)
|
||||
ById(id string) (*ExtensionImplementation, error)
|
||||
Delete(container *ExtensionImplementation) error
|
||||
}
|
||||
|
||||
func newExtensionImplementationClient(rancherClient *RancherClient) *ExtensionImplementationClient {
|
||||
return &ExtensionImplementationClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExtensionImplementationClient) Create(container *ExtensionImplementation) (*ExtensionImplementation, error) {
|
||||
resp := &ExtensionImplementation{}
|
||||
err := c.rancherClient.doCreate(EXTENSION_IMPLEMENTATION_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExtensionImplementationClient) Update(existing *ExtensionImplementation, updates interface{}) (*ExtensionImplementation, error) {
|
||||
resp := &ExtensionImplementation{}
|
||||
err := c.rancherClient.doUpdate(EXTENSION_IMPLEMENTATION_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExtensionImplementationClient) List(opts *ListOpts) (*ExtensionImplementationCollection, error) {
|
||||
resp := &ExtensionImplementationCollection{}
|
||||
err := c.rancherClient.doList(EXTENSION_IMPLEMENTATION_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExtensionImplementationCollection) Next() (*ExtensionImplementationCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExtensionImplementationCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExtensionImplementationClient) ById(id string) (*ExtensionImplementation, error) {
|
||||
resp := &ExtensionImplementation{}
|
||||
err := c.rancherClient.doById(EXTENSION_IMPLEMENTATION_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExtensionImplementationClient) Delete(container *ExtensionImplementation) error {
|
||||
return c.rancherClient.doResourceDelete(EXTENSION_IMPLEMENTATION_TYPE, &container.Resource)
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTENSION_POINT_TYPE = "extensionPoint"
|
||||
)
|
||||
|
||||
type ExtensionPoint struct {
|
||||
Resource
|
||||
|
||||
ExcludeSetting string `json:"excludeSetting,omitempty" yaml:"exclude_setting,omitempty"`
|
||||
|
||||
Implementations []ExtensionImplementation `json:"implementations,omitempty" yaml:"implementations,omitempty"`
|
||||
|
||||
IncludeSetting string `json:"includeSetting,omitempty" yaml:"include_setting,omitempty"`
|
||||
|
||||
ListSetting string `json:"listSetting,omitempty" yaml:"list_setting,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
}
|
||||
|
||||
type ExtensionPointCollection struct {
|
||||
Collection
|
||||
Data []ExtensionPoint `json:"data,omitempty"`
|
||||
client *ExtensionPointClient
|
||||
}
|
||||
|
||||
type ExtensionPointClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExtensionPointOperations interface {
|
||||
List(opts *ListOpts) (*ExtensionPointCollection, error)
|
||||
Create(opts *ExtensionPoint) (*ExtensionPoint, error)
|
||||
Update(existing *ExtensionPoint, updates interface{}) (*ExtensionPoint, error)
|
||||
ById(id string) (*ExtensionPoint, error)
|
||||
Delete(container *ExtensionPoint) error
|
||||
}
|
||||
|
||||
func newExtensionPointClient(rancherClient *RancherClient) *ExtensionPointClient {
|
||||
return &ExtensionPointClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExtensionPointClient) Create(container *ExtensionPoint) (*ExtensionPoint, error) {
|
||||
resp := &ExtensionPoint{}
|
||||
err := c.rancherClient.doCreate(EXTENSION_POINT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExtensionPointClient) Update(existing *ExtensionPoint, updates interface{}) (*ExtensionPoint, error) {
|
||||
resp := &ExtensionPoint{}
|
||||
err := c.rancherClient.doUpdate(EXTENSION_POINT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExtensionPointClient) List(opts *ListOpts) (*ExtensionPointCollection, error) {
|
||||
resp := &ExtensionPointCollection{}
|
||||
err := c.rancherClient.doList(EXTENSION_POINT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExtensionPointCollection) Next() (*ExtensionPointCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExtensionPointCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExtensionPointClient) ById(id string) (*ExtensionPoint, error) {
|
||||
resp := &ExtensionPoint{}
|
||||
err := c.rancherClient.doById(EXTENSION_POINT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExtensionPointClient) Delete(container *ExtensionPoint) error {
|
||||
return c.rancherClient.doResourceDelete(EXTENSION_POINT_TYPE, &container.Resource)
|
||||
}
|
||||
-129
@@ -1,129 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTERNAL_DNS_EVENT_TYPE = "externalDnsEvent"
|
||||
)
|
||||
|
||||
type ExternalDnsEvent struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
Fqdn string `json:"fqdn,omitempty" yaml:"fqdn,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"`
|
||||
|
||||
ServiceName string `json:"serviceName,omitempty" yaml:"service_name,omitempty"`
|
||||
|
||||
StackName string `json:"stackName,omitempty" yaml:"stack_name,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalDnsEventCollection struct {
|
||||
Collection
|
||||
Data []ExternalDnsEvent `json:"data,omitempty"`
|
||||
client *ExternalDnsEventClient
|
||||
}
|
||||
|
||||
type ExternalDnsEventClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExternalDnsEventOperations interface {
|
||||
List(opts *ListOpts) (*ExternalDnsEventCollection, error)
|
||||
Create(opts *ExternalDnsEvent) (*ExternalDnsEvent, error)
|
||||
Update(existing *ExternalDnsEvent, updates interface{}) (*ExternalDnsEvent, error)
|
||||
ById(id string) (*ExternalDnsEvent, error)
|
||||
Delete(container *ExternalDnsEvent) error
|
||||
|
||||
ActionCreate(*ExternalDnsEvent) (*ExternalEvent, error)
|
||||
|
||||
ActionRemove(*ExternalDnsEvent) (*ExternalEvent, error)
|
||||
}
|
||||
|
||||
func newExternalDnsEventClient(rancherClient *RancherClient) *ExternalDnsEventClient {
|
||||
return &ExternalDnsEventClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExternalDnsEventClient) Create(container *ExternalDnsEvent) (*ExternalDnsEvent, error) {
|
||||
resp := &ExternalDnsEvent{}
|
||||
err := c.rancherClient.doCreate(EXTERNAL_DNS_EVENT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalDnsEventClient) Update(existing *ExternalDnsEvent, updates interface{}) (*ExternalDnsEvent, error) {
|
||||
resp := &ExternalDnsEvent{}
|
||||
err := c.rancherClient.doUpdate(EXTERNAL_DNS_EVENT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalDnsEventClient) List(opts *ListOpts) (*ExternalDnsEventCollection, error) {
|
||||
resp := &ExternalDnsEventCollection{}
|
||||
err := c.rancherClient.doList(EXTERNAL_DNS_EVENT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExternalDnsEventCollection) Next() (*ExternalDnsEventCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExternalDnsEventCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExternalDnsEventClient) ById(id string) (*ExternalDnsEvent, error) {
|
||||
resp := &ExternalDnsEvent{}
|
||||
err := c.rancherClient.doById(EXTERNAL_DNS_EVENT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalDnsEventClient) Delete(container *ExternalDnsEvent) error {
|
||||
return c.rancherClient.doResourceDelete(EXTERNAL_DNS_EVENT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ExternalDnsEventClient) ActionCreate(resource *ExternalDnsEvent) (*ExternalEvent, error) {
|
||||
|
||||
resp := &ExternalEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_DNS_EVENT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalDnsEventClient) ActionRemove(resource *ExternalDnsEvent) (*ExternalEvent, error) {
|
||||
|
||||
resp := &ExternalEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_DNS_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTERNAL_EVENT_TYPE = "externalEvent"
|
||||
)
|
||||
|
||||
type ExternalEvent struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalEventCollection struct {
|
||||
Collection
|
||||
Data []ExternalEvent `json:"data,omitempty"`
|
||||
client *ExternalEventClient
|
||||
}
|
||||
|
||||
type ExternalEventClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExternalEventOperations interface {
|
||||
List(opts *ListOpts) (*ExternalEventCollection, error)
|
||||
Create(opts *ExternalEvent) (*ExternalEvent, error)
|
||||
Update(existing *ExternalEvent, updates interface{}) (*ExternalEvent, error)
|
||||
ById(id string) (*ExternalEvent, error)
|
||||
Delete(container *ExternalEvent) error
|
||||
|
||||
ActionCreate(*ExternalEvent) (*ExternalEvent, error)
|
||||
|
||||
ActionRemove(*ExternalEvent) (*ExternalEvent, error)
|
||||
}
|
||||
|
||||
func newExternalEventClient(rancherClient *RancherClient) *ExternalEventClient {
|
||||
return &ExternalEventClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExternalEventClient) Create(container *ExternalEvent) (*ExternalEvent, error) {
|
||||
resp := &ExternalEvent{}
|
||||
err := c.rancherClient.doCreate(EXTERNAL_EVENT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalEventClient) Update(existing *ExternalEvent, updates interface{}) (*ExternalEvent, error) {
|
||||
resp := &ExternalEvent{}
|
||||
err := c.rancherClient.doUpdate(EXTERNAL_EVENT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalEventClient) List(opts *ListOpts) (*ExternalEventCollection, error) {
|
||||
resp := &ExternalEventCollection{}
|
||||
err := c.rancherClient.doList(EXTERNAL_EVENT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExternalEventCollection) Next() (*ExternalEventCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExternalEventCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExternalEventClient) ById(id string) (*ExternalEvent, error) {
|
||||
resp := &ExternalEvent{}
|
||||
err := c.rancherClient.doById(EXTERNAL_EVENT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalEventClient) Delete(container *ExternalEvent) error {
|
||||
return c.rancherClient.doResourceDelete(EXTERNAL_EVENT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ExternalEventClient) ActionCreate(resource *ExternalEvent) (*ExternalEvent, error) {
|
||||
|
||||
resp := &ExternalEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_EVENT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalEventClient) ActionRemove(resource *ExternalEvent) (*ExternalEvent, error) {
|
||||
|
||||
resp := &ExternalEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-175
@@ -1,175 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTERNAL_HANDLER_TYPE = "externalHandler"
|
||||
)
|
||||
|
||||
type ExternalHandler struct {
|
||||
Resource
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Priority int64 `json:"priority,omitempty" yaml:"priority,omitempty"`
|
||||
|
||||
ProcessConfigs []ExternalHandlerProcessConfig `json:"processConfigs,omitempty" yaml:"process_configs,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
Retries int64 `json:"retries,omitempty" yaml:"retries,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
TimeoutMillis int64 `json:"timeoutMillis,omitempty" yaml:"timeout_millis,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalHandlerCollection struct {
|
||||
Collection
|
||||
Data []ExternalHandler `json:"data,omitempty"`
|
||||
client *ExternalHandlerClient
|
||||
}
|
||||
|
||||
type ExternalHandlerClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExternalHandlerOperations interface {
|
||||
List(opts *ListOpts) (*ExternalHandlerCollection, error)
|
||||
Create(opts *ExternalHandler) (*ExternalHandler, error)
|
||||
Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error)
|
||||
ById(id string) (*ExternalHandler, error)
|
||||
Delete(container *ExternalHandler) error
|
||||
|
||||
ActionActivate(*ExternalHandler) (*ExternalHandler, error)
|
||||
|
||||
ActionCreate(*ExternalHandler) (*ExternalHandler, error)
|
||||
|
||||
ActionDeactivate(*ExternalHandler) (*ExternalHandler, error)
|
||||
|
||||
ActionPurge(*ExternalHandler) (*ExternalHandler, error)
|
||||
|
||||
ActionRemove(*ExternalHandler) (*ExternalHandler, error)
|
||||
|
||||
ActionUpdate(*ExternalHandler) (*ExternalHandler, error)
|
||||
}
|
||||
|
||||
func newExternalHandlerClient(rancherClient *RancherClient) *ExternalHandlerClient {
|
||||
return &ExternalHandlerClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) Create(container *ExternalHandler) (*ExternalHandler, error) {
|
||||
resp := &ExternalHandler{}
|
||||
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) Update(existing *ExternalHandler, updates interface{}) (*ExternalHandler, error) {
|
||||
resp := &ExternalHandler{}
|
||||
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) List(opts *ListOpts) (*ExternalHandlerCollection, error) {
|
||||
resp := &ExternalHandlerCollection{}
|
||||
err := c.rancherClient.doList(EXTERNAL_HANDLER_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExternalHandlerCollection) Next() (*ExternalHandlerCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExternalHandlerCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) ById(id string) (*ExternalHandler, error) {
|
||||
resp := &ExternalHandler{}
|
||||
err := c.rancherClient.doById(EXTERNAL_HANDLER_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) Delete(container *ExternalHandler) error {
|
||||
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) ActionActivate(resource *ExternalHandler) (*ExternalHandler, error) {
|
||||
|
||||
resp := &ExternalHandler{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) ActionCreate(resource *ExternalHandler) (*ExternalHandler, error) {
|
||||
|
||||
resp := &ExternalHandler{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) ActionDeactivate(resource *ExternalHandler) (*ExternalHandler, error) {
|
||||
|
||||
resp := &ExternalHandler{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) ActionPurge(resource *ExternalHandler) (*ExternalHandler, error) {
|
||||
|
||||
resp := &ExternalHandler{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) ActionRemove(resource *ExternalHandler) (*ExternalHandler, error) {
|
||||
|
||||
resp := &ExternalHandler{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerClient) ActionUpdate(resource *ExternalHandler) (*ExternalHandler, error) {
|
||||
|
||||
resp := &ExternalHandler{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Generated
Vendored
-175
@@ -1,175 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE = "externalHandlerExternalHandlerProcessMap"
|
||||
)
|
||||
|
||||
type ExternalHandlerExternalHandlerProcessMap struct {
|
||||
Resource
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
EventName string `json:"eventName,omitempty" yaml:"event_name,omitempty"`
|
||||
|
||||
ExternalHandlerId string `json:"externalHandlerId,omitempty" yaml:"external_handler_id,omitempty"`
|
||||
|
||||
ExternalHandlerProcessId string `json:"externalHandlerProcessId,omitempty" yaml:"external_handler_process_id,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
OnError string `json:"onError,omitempty" yaml:"on_error,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalHandlerExternalHandlerProcessMapCollection struct {
|
||||
Collection
|
||||
Data []ExternalHandlerExternalHandlerProcessMap `json:"data,omitempty"`
|
||||
client *ExternalHandlerExternalHandlerProcessMapClient
|
||||
}
|
||||
|
||||
type ExternalHandlerExternalHandlerProcessMapClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExternalHandlerExternalHandlerProcessMapOperations interface {
|
||||
List(opts *ListOpts) (*ExternalHandlerExternalHandlerProcessMapCollection, error)
|
||||
Create(opts *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
Update(existing *ExternalHandlerExternalHandlerProcessMap, updates interface{}) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
ById(id string) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
Delete(container *ExternalHandlerExternalHandlerProcessMap) error
|
||||
|
||||
ActionActivate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
|
||||
ActionCreate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
|
||||
ActionDeactivate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
|
||||
ActionPurge(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
|
||||
ActionRemove(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
|
||||
ActionUpdate(*ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error)
|
||||
}
|
||||
|
||||
func newExternalHandlerExternalHandlerProcessMapClient(rancherClient *RancherClient) *ExternalHandlerExternalHandlerProcessMapClient {
|
||||
return &ExternalHandlerExternalHandlerProcessMapClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) Create(container *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) Update(existing *ExternalHandlerExternalHandlerProcessMap, updates interface{}) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) List(opts *ListOpts) (*ExternalHandlerExternalHandlerProcessMapCollection, error) {
|
||||
resp := &ExternalHandlerExternalHandlerProcessMapCollection{}
|
||||
err := c.rancherClient.doList(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExternalHandlerExternalHandlerProcessMapCollection) Next() (*ExternalHandlerExternalHandlerProcessMapCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExternalHandlerExternalHandlerProcessMapCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) ById(id string) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
err := c.rancherClient.doById(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) Delete(container *ExternalHandlerExternalHandlerProcessMap) error {
|
||||
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionActivate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionCreate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionDeactivate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionPurge(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionRemove(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerExternalHandlerProcessMapClient) ActionUpdate(resource *ExternalHandlerExternalHandlerProcessMap) (*ExternalHandlerExternalHandlerProcessMap, error) {
|
||||
|
||||
resp := &ExternalHandlerExternalHandlerProcessMap{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_EXTERNAL_HANDLER_PROCESS_MAP_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTERNAL_HANDLER_PROCESS_TYPE = "externalHandlerProcess"
|
||||
)
|
||||
|
||||
type ExternalHandlerProcess struct {
|
||||
Resource
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalHandlerProcessCollection struct {
|
||||
Collection
|
||||
Data []ExternalHandlerProcess `json:"data,omitempty"`
|
||||
client *ExternalHandlerProcessClient
|
||||
}
|
||||
|
||||
type ExternalHandlerProcessClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExternalHandlerProcessOperations interface {
|
||||
List(opts *ListOpts) (*ExternalHandlerProcessCollection, error)
|
||||
Create(opts *ExternalHandlerProcess) (*ExternalHandlerProcess, error)
|
||||
Update(existing *ExternalHandlerProcess, updates interface{}) (*ExternalHandlerProcess, error)
|
||||
ById(id string) (*ExternalHandlerProcess, error)
|
||||
Delete(container *ExternalHandlerProcess) error
|
||||
|
||||
ActionActivate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
|
||||
|
||||
ActionCreate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
|
||||
|
||||
ActionDeactivate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
|
||||
|
||||
ActionPurge(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
|
||||
|
||||
ActionRemove(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
|
||||
|
||||
ActionUpdate(*ExternalHandlerProcess) (*ExternalHandlerProcess, error)
|
||||
}
|
||||
|
||||
func newExternalHandlerProcessClient(rancherClient *RancherClient) *ExternalHandlerProcessClient {
|
||||
return &ExternalHandlerProcessClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) Create(container *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
|
||||
resp := &ExternalHandlerProcess{}
|
||||
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_PROCESS_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) Update(existing *ExternalHandlerProcess, updates interface{}) (*ExternalHandlerProcess, error) {
|
||||
resp := &ExternalHandlerProcess{}
|
||||
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_PROCESS_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) List(opts *ListOpts) (*ExternalHandlerProcessCollection, error) {
|
||||
resp := &ExternalHandlerProcessCollection{}
|
||||
err := c.rancherClient.doList(EXTERNAL_HANDLER_PROCESS_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExternalHandlerProcessCollection) Next() (*ExternalHandlerProcessCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExternalHandlerProcessCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) ById(id string) (*ExternalHandlerProcess, error) {
|
||||
resp := &ExternalHandlerProcess{}
|
||||
err := c.rancherClient.doById(EXTERNAL_HANDLER_PROCESS_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) Delete(container *ExternalHandlerProcess) error {
|
||||
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_PROCESS_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) ActionActivate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
|
||||
|
||||
resp := &ExternalHandlerProcess{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) ActionCreate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
|
||||
|
||||
resp := &ExternalHandlerProcess{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) ActionDeactivate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
|
||||
|
||||
resp := &ExternalHandlerProcess{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) ActionPurge(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
|
||||
|
||||
resp := &ExternalHandlerProcess{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) ActionRemove(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
|
||||
|
||||
resp := &ExternalHandlerProcess{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessClient) ActionUpdate(resource *ExternalHandlerProcess) (*ExternalHandlerProcess, error) {
|
||||
|
||||
resp := &ExternalHandlerProcess{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HANDLER_PROCESS_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Generated
Vendored
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE = "externalHandlerProcessConfig"
|
||||
)
|
||||
|
||||
type ExternalHandlerProcessConfig struct {
|
||||
Resource
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
OnError string `json:"onError,omitempty" yaml:"on_error,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalHandlerProcessConfigCollection struct {
|
||||
Collection
|
||||
Data []ExternalHandlerProcessConfig `json:"data,omitempty"`
|
||||
client *ExternalHandlerProcessConfigClient
|
||||
}
|
||||
|
||||
type ExternalHandlerProcessConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExternalHandlerProcessConfigOperations interface {
|
||||
List(opts *ListOpts) (*ExternalHandlerProcessConfigCollection, error)
|
||||
Create(opts *ExternalHandlerProcessConfig) (*ExternalHandlerProcessConfig, error)
|
||||
Update(existing *ExternalHandlerProcessConfig, updates interface{}) (*ExternalHandlerProcessConfig, error)
|
||||
ById(id string) (*ExternalHandlerProcessConfig, error)
|
||||
Delete(container *ExternalHandlerProcessConfig) error
|
||||
}
|
||||
|
||||
func newExternalHandlerProcessConfigClient(rancherClient *RancherClient) *ExternalHandlerProcessConfigClient {
|
||||
return &ExternalHandlerProcessConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessConfigClient) Create(container *ExternalHandlerProcessConfig) (*ExternalHandlerProcessConfig, error) {
|
||||
resp := &ExternalHandlerProcessConfig{}
|
||||
err := c.rancherClient.doCreate(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessConfigClient) Update(existing *ExternalHandlerProcessConfig, updates interface{}) (*ExternalHandlerProcessConfig, error) {
|
||||
resp := &ExternalHandlerProcessConfig{}
|
||||
err := c.rancherClient.doUpdate(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessConfigClient) List(opts *ListOpts) (*ExternalHandlerProcessConfigCollection, error) {
|
||||
resp := &ExternalHandlerProcessConfigCollection{}
|
||||
err := c.rancherClient.doList(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExternalHandlerProcessConfigCollection) Next() (*ExternalHandlerProcessConfigCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExternalHandlerProcessConfigCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessConfigClient) ById(id string) (*ExternalHandlerProcessConfig, error) {
|
||||
resp := &ExternalHandlerProcessConfig{}
|
||||
err := c.rancherClient.doById(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHandlerProcessConfigClient) Delete(container *ExternalHandlerProcessConfig) error {
|
||||
return c.rancherClient.doResourceDelete(EXTERNAL_HANDLER_PROCESS_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-129
@@ -1,129 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXTERNAL_HOST_EVENT_TYPE = "externalHostEvent"
|
||||
)
|
||||
|
||||
type ExternalHostEvent struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
DeleteHost bool `json:"deleteHost,omitempty" yaml:"delete_host,omitempty"`
|
||||
|
||||
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
|
||||
|
||||
HostLabel string `json:"hostLabel,omitempty" yaml:"host_label,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
ReportedAccountId string `json:"reportedAccountId,omitempty" yaml:"reported_account_id,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
Transitioning string `json:"transitioning,omitempty" yaml:"transitioning,omitempty"`
|
||||
|
||||
TransitioningMessage string `json:"transitioningMessage,omitempty" yaml:"transitioning_message,omitempty"`
|
||||
|
||||
TransitioningProgress int64 `json:"transitioningProgress,omitempty" yaml:"transitioning_progress,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalHostEventCollection struct {
|
||||
Collection
|
||||
Data []ExternalHostEvent `json:"data,omitempty"`
|
||||
client *ExternalHostEventClient
|
||||
}
|
||||
|
||||
type ExternalHostEventClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExternalHostEventOperations interface {
|
||||
List(opts *ListOpts) (*ExternalHostEventCollection, error)
|
||||
Create(opts *ExternalHostEvent) (*ExternalHostEvent, error)
|
||||
Update(existing *ExternalHostEvent, updates interface{}) (*ExternalHostEvent, error)
|
||||
ById(id string) (*ExternalHostEvent, error)
|
||||
Delete(container *ExternalHostEvent) error
|
||||
|
||||
ActionCreate(*ExternalHostEvent) (*ExternalEvent, error)
|
||||
|
||||
ActionRemove(*ExternalHostEvent) (*ExternalEvent, error)
|
||||
}
|
||||
|
||||
func newExternalHostEventClient(rancherClient *RancherClient) *ExternalHostEventClient {
|
||||
return &ExternalHostEventClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExternalHostEventClient) Create(container *ExternalHostEvent) (*ExternalHostEvent, error) {
|
||||
resp := &ExternalHostEvent{}
|
||||
err := c.rancherClient.doCreate(EXTERNAL_HOST_EVENT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHostEventClient) Update(existing *ExternalHostEvent, updates interface{}) (*ExternalHostEvent, error) {
|
||||
resp := &ExternalHostEvent{}
|
||||
err := c.rancherClient.doUpdate(EXTERNAL_HOST_EVENT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHostEventClient) List(opts *ListOpts) (*ExternalHostEventCollection, error) {
|
||||
resp := &ExternalHostEventCollection{}
|
||||
err := c.rancherClient.doList(EXTERNAL_HOST_EVENT_TYPE, opts, resp)
|
||||
resp.client = c
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (cc *ExternalHostEventCollection) Next() (*ExternalHostEventCollection, error) {
|
||||
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
|
||||
resp := &ExternalHostEventCollection{}
|
||||
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
|
||||
resp.client = cc.client
|
||||
return resp, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (c *ExternalHostEventClient) ById(id string) (*ExternalHostEvent, error) {
|
||||
resp := &ExternalHostEvent{}
|
||||
err := c.rancherClient.doById(EXTERNAL_HOST_EVENT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHostEventClient) Delete(container *ExternalHostEvent) error {
|
||||
return c.rancherClient.doResourceDelete(EXTERNAL_HOST_EVENT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ExternalHostEventClient) ActionCreate(resource *ExternalHostEvent) (*ExternalEvent, error) {
|
||||
|
||||
resp := &ExternalEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HOST_EVENT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExternalHostEventClient) ActionRemove(resource *ExternalHostEvent) (*ExternalEvent, error) {
|
||||
|
||||
resp := &ExternalEvent{}
|
||||
|
||||
err := c.rancherClient.doAction(EXTERNAL_HOST_EVENT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user