mirror of
https://github.com/josmo/drone-rancher.git
synced 2026-06-16 14:50:35 +08:00
Compare commits
37 Commits
release/0.4
..
1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| ce418ca35c | |||
| 84e93ab37f | |||
| be6a3df05a | |||
| 919d7342e7 | |||
| 468da92a86 | |||
| 1b6e9d0959 | |||
| 7c54eb7346 | |||
| 4e9ec0d5c0 | |||
| de92c986fd | |||
| 4151ba4692 | |||
| a1d6c60780 | |||
| a598275158 | |||
| 53fc3144b3 | |||
| db325c6338 | |||
| aff3124306 | |||
| 2fc4d2010d | |||
| 512145144d | |||
| 3adf161081 | |||
| 168f61a725 | |||
| 2e2059feb5 | |||
| da6872ea1f | |||
| 1aadd0c87e | |||
| 14e5d2d2c3 | |||
| 92dc08090d | |||
| aa7964da72 | |||
| 7c7f8ef0ec | |||
| 29db1e8e8b | |||
| f0e574c8ba | |||
| 27ad82d9af | |||
| debf13c598 | |||
| eca094a74d | |||
| 552cbf6d18 | |||
| 23e0b745f2 | |||
| 3c909dadfc | |||
| e215fadb35 | |||
| 065c9d4f4f | |||
| 7e02dbece4 |
Regular → Executable
+89
-22
@@ -1,26 +1,93 @@
|
||||
workspace:
|
||||
base: /go
|
||||
path: src/github.com/josmo/drone-rancher
|
||||
pipeline:
|
||||
test:
|
||||
image: golang:1.6
|
||||
environment:
|
||||
- CGO_ENABLED=0
|
||||
- GOPATH=/drone
|
||||
image: golang:1.9
|
||||
commands:
|
||||
- make vet
|
||||
- make build
|
||||
- make test
|
||||
docker:
|
||||
storage_driver: overlay
|
||||
repo: plugins/drone-rancher
|
||||
tag: [ "latest" ]
|
||||
when:
|
||||
branch: release/0.4
|
||||
event: push
|
||||
- go vet
|
||||
- go test -cover -coverprofile=coverage.out
|
||||
|
||||
plugin:
|
||||
name: Rancher
|
||||
desc: Deploy or update a project on Rancher
|
||||
type: deploy
|
||||
image: plugins/drone-rancher
|
||||
labels:
|
||||
- rancher
|
||||
- docker
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
publish_linux_amd64:
|
||||
image: plugins/docker
|
||||
username: josmo
|
||||
repo: peloton/drone-rancher
|
||||
auto_tag: true
|
||||
secrets: [ docker_password ]
|
||||
dockerfile: Dockerfile
|
||||
when:
|
||||
event: tag
|
||||
|
||||
publish_linux_arm64:
|
||||
image: plugins/docker
|
||||
username: josmo
|
||||
repo: peloton/drone-rancher
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm64
|
||||
secrets: [ docker_password ]
|
||||
dockerfile: Dockerfile.arm64
|
||||
when:
|
||||
event: tag
|
||||
|
||||
publish_linux_arm:
|
||||
image: plugins/docker
|
||||
username: josmo
|
||||
repo: peloton/drone-rancher
|
||||
auto_tag: true
|
||||
auto_tag_suffix: linux-arm
|
||||
secrets: [ docker_password ]
|
||||
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
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgdGVzdDoKICAgIGltYWdlOiBnb2xhbmc6MS42CiAgICBlbnZpcm9ubWVudDoKICAgICAgLSBDR09fRU5BQkxFRD0wCiAgICAgIC0gR09QQVRIPS9kcm9uZQogICAgY29tbWFuZHM6CiAgICAgIC0gbWFrZSB2ZXQKICAgICAgLSBtYWtlIGJ1aWxkCiAgICAgIC0gbWFrZSB0ZXN0CiAgZG9ja2VyOgogICAgc3RvcmFnZV9kcml2ZXI6IG92ZXJsYXkKICAgIHJlcG86IHBsdWdpbnMvZHJvbmUtcmFuY2hlcgogICAgdGFnOiBbICJsYXRlc3QiIF0KICAgIHdoZW46CiAgICAgIGJyYW5jaDogcmVsZWFzZS8wLjQKICAgICAgZXZlbnQ6IHB1c2gKCnBsdWdpbjoKICBuYW1lOiBSYW5jaGVyCiAgZGVzYzogRGVwbG95IG9yIHVwZGF0ZSBhIHByb2plY3Qgb24gUmFuY2hlcgogIHR5cGU6IGRlcGxveQogIGltYWdlOiBwbHVnaW5zL2Ryb25lLXJhbmNoZXIKICBsYWJlbHM6CiAgICAtIHJhbmNoZXIKICAgIC0gZG9ja2VyCg.Amvq0DkNvNUvgzDfSqI7H0xChF8iJu2IPKiheQfclhE
|
||||
Regular → Executable
+2
@@ -25,3 +25,5 @@ _testmain.go
|
||||
|
||||
coverage.out
|
||||
drone-rancher
|
||||
|
||||
*.idea
|
||||
|
||||
@@ -3,19 +3,22 @@ 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
|
||||
- `access_key` - rancher api access key
|
||||
- `secret_key` - rancher api secret key
|
||||
- `rancher_access_key` - rancher api access key
|
||||
- `rancher_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`)
|
||||
- `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`
|
||||
- `interval_millis` - the upgrade interval in milli seconds, defaults to `1000`
|
||||
- `batch_size` - the upgrade batch size, defaults to `1`
|
||||
|
||||
The following is a sample Rancher configuration in your `.drone.yml` file:
|
||||
|
||||
```yaml
|
||||
deploy:
|
||||
rancher:
|
||||
image: peloton/drone-rancher
|
||||
url: https://example.rancher.com
|
||||
access_key: 1234567abcdefg
|
||||
secret_key: abcdefg1234567
|
||||
@@ -23,4 +26,7 @@ deploy:
|
||||
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
|
||||
|
||||
|
||||
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.
|
||||
|
||||
Regular → Executable
+14
-9
@@ -1,11 +1,16 @@
|
||||
# Docker image for the Drone build runner
|
||||
#
|
||||
# CGO_ENABLED=0 go build -a -tags netgo
|
||||
# docker build --rm=true -t plugins/drone-rancher .
|
||||
FROM alpine:3.6 as alpine
|
||||
RUN apk add -U --no-cache ca-certificates
|
||||
|
||||
FROM gliderlabs/alpine:3.2
|
||||
RUN apk add --update \
|
||||
ca-certificates
|
||||
ADD drone-rancher /bin/
|
||||
FROM scratch
|
||||
|
||||
ENV GODEBUG=netdns=go
|
||||
|
||||
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
LABEL org.label-schema.version=latest
|
||||
LABEL org.label-schema.vcs-url="https://github.com/josmo/drone-rancher.git"
|
||||
LABEL org.label-schema.name="Drone Rancher"
|
||||
LABEL org.label-schema.vendor="Josmo"
|
||||
|
||||
ADD release/linux/amd64/drone-rancher /bin/
|
||||
ENTRYPOINT ["/bin/drone-rancher"]
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM alpine:3.6 as alpine
|
||||
RUN apk add -U --no-cache ca-certificates
|
||||
|
||||
FROM scratch
|
||||
|
||||
ENV GODEBUG=netdns=go
|
||||
|
||||
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
LABEL org.label-schema.version=latest
|
||||
LABEL org.label-schema.vcs-url="https://github.com/josmo/drone-rancher.git"
|
||||
LABEL org.label-schema.name="Drone Rancher"
|
||||
LABEL org.label-schema.vendor="Josmo"
|
||||
LABEL org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/arm/drone-rancher /bin/
|
||||
ENTRYPOINT ["/bin/drone-rancher"]
|
||||
@@ -0,0 +1,17 @@
|
||||
FROM alpine:3.6 as alpine
|
||||
RUN apk add -U --no-cache ca-certificates
|
||||
|
||||
FROM scratch
|
||||
|
||||
ENV GODEBUG=netdns=go
|
||||
|
||||
COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||
|
||||
LABEL org.label-schema.version=latest
|
||||
LABEL org.label-schema.vcs-url="https://github.com/josmo/drone-rancher.git"
|
||||
LABEL org.label-schema.name="Drone Rancher"
|
||||
LABEL org.label-schema.vendor="Josmo"
|
||||
LABEL org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/linux/arm64/drone-rancher /bin/
|
||||
ENTRYPOINT ["/bin/drone-rancher"]
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM microsoft/nanoserver:latest
|
||||
|
||||
ENV GODEBUG=netdns=go
|
||||
|
||||
LABEL org.label-schema.version=latest
|
||||
LABEL org.label-schema.vcs-url="https://github.com/josmo/drone-rancher.git"
|
||||
LABEL org.label-schema.name="Drone Rancher"
|
||||
LABEL org.label-schema.vendor="Josmo"
|
||||
LABEL org.label-schema.schema-version="1.0"
|
||||
|
||||
ADD release/windows/amd64/drone-rancher /bin/
|
||||
ENTRYPOINT [ "/bin/drone-rancher" ]
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
[people]
|
||||
[people.bradrydzewski]
|
||||
name = "Brad Rydzewski"
|
||||
email = "brad@drone.io"
|
||||
login = "bradrydzewski"
|
||||
[people.Bugagazavr]
|
||||
name = "Kirill"
|
||||
email = ""
|
||||
login = "Bugagazavr"
|
||||
[people.donny-dont]
|
||||
name = "Don Olmstead"
|
||||
email = "donny-dont@gmail.com"
|
||||
login = "donny-dont"
|
||||
[people.jackspirou]
|
||||
name = "Jack Spirou"
|
||||
email = ""
|
||||
login = "jackspirou"
|
||||
[people.msteinert]
|
||||
name = "Mike Steinert"
|
||||
email = ""
|
||||
login = "msteinert"
|
||||
[people.nlf]
|
||||
name = "Nathan LaFreniere"
|
||||
email = ""
|
||||
login = "nlf"
|
||||
[people.tboerger]
|
||||
name = "Thomas Boerger"
|
||||
email = "thomas@webhippie.de"
|
||||
login = "tboerger"
|
||||
[people.athieriot]
|
||||
name = "Aurélien Thieriot"
|
||||
email = "a.thieriot@gmail.com"
|
||||
login = "athieriot"
|
||||
|
||||
[org]
|
||||
[org.core]
|
||||
people = [
|
||||
"bradrydzewski",
|
||||
"Bugagazavr",
|
||||
"donny-dont",
|
||||
"jackspirou",
|
||||
"msteinert",
|
||||
"nlf",
|
||||
"tboerger",
|
||||
"athieriot"
|
||||
]
|
||||
@@ -1,34 +0,0 @@
|
||||
.PHONY: all clean deps fmt vet test docker
|
||||
|
||||
EXECUTABLE ?= drone-rancher
|
||||
IMAGE ?= plugins/$(EXECUTABLE)
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD)
|
||||
|
||||
LDFLAGS = -X "main.buildCommit=$(COMMIT)"
|
||||
PACKAGES = $(shell go list ./... | grep -v /vendor/)
|
||||
|
||||
all: deps build test
|
||||
|
||||
clean:
|
||||
go clean -i ./...
|
||||
|
||||
deps:
|
||||
go get -t ./...
|
||||
|
||||
fmt:
|
||||
go fmt $(PACKAGES)
|
||||
|
||||
vet:
|
||||
go vet $(PACKAGES)
|
||||
|
||||
test:
|
||||
@for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done;
|
||||
|
||||
docker:
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-s -w $(LDFLAGS)'
|
||||
docker build --rm -t $(IMAGE) .
|
||||
|
||||
$(EXECUTABLE): $(wildcard *.go)
|
||||
go build -ldflags '-s -w $(LDFLAGS)'
|
||||
|
||||
build: $(EXECUTABLE)
|
||||
@@ -1,107 +1,35 @@
|
||||
# drone-rancher
|
||||
|
||||
[](http://beta.drone.io/drone-plugins/drone-rancher)
|
||||
[](https://aircover.co/drone-plugins/drone-rancher)
|
||||
[](https://imagelayers.io/?images=plugins/drone-rancher:latest 'Get your own badge on imagelayers.io')
|
||||
[](https://drone.seattleslow.com/josmo/drone-rancher)
|
||||
[](https://gitter.im/drone/drone)
|
||||
[](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")
|
||||
|
||||
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).
|
||||
|
||||
## Binary
|
||||
|
||||
Build the binary using `make`:
|
||||
Build the binary using `drone cli`:
|
||||
|
||||
```
|
||||
make deps build
|
||||
drone exec
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```sh
|
||||
./drone-rancher <<EOF
|
||||
{
|
||||
"repo": {
|
||||
"clone_url": "git://github.com/drone/drone",
|
||||
"owner": "drone",
|
||||
"name": "drone",
|
||||
"full_name": "drone/drone"
|
||||
},
|
||||
"system": {
|
||||
"link_url": "https://beta.drone.io"
|
||||
},
|
||||
"build": {
|
||||
"number": 22,
|
||||
"status": "success",
|
||||
"started_at": 1421029603,
|
||||
"finished_at": 1421029813,
|
||||
"message": "Update the Readme",
|
||||
"author": "johnsmith",
|
||||
"author_email": "john.smith@gmail.com"
|
||||
"event": "push",
|
||||
"branch": "master",
|
||||
"commit": "436b7a6e2abaddfd35740527353e78a227ddcb2c",
|
||||
"ref": "refs/heads/master"
|
||||
},
|
||||
"workspace": {
|
||||
"root": "/drone/src",
|
||||
"path": "/drone/src/github.com/drone/drone"
|
||||
},
|
||||
"vargs": {
|
||||
"url": "https://example.rancher.com",
|
||||
"access_key": "1234567abcdefg",
|
||||
"secret_key": "abcdefg1234567",
|
||||
"service": "drone/drone",
|
||||
"docker_image": "drone/drone:latest"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
```
|
||||
## Usage
|
||||
|
||||
## Docker
|
||||
|
||||
Build the container using `make`:
|
||||
Build and deploy from your current working directory:
|
||||
|
||||
```
|
||||
make deps docker
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```sh
|
||||
docker run -i plugins/drone-rancher <<EOF
|
||||
{
|
||||
"repo": {
|
||||
"clone_url": "git://github.com/drone/drone",
|
||||
"owner": "drone",
|
||||
"name": "drone",
|
||||
"full_name": "drone/drone"
|
||||
},
|
||||
"system": {
|
||||
"link_url": "https://beta.drone.io"
|
||||
},
|
||||
"build": {
|
||||
"number": 22,
|
||||
"status": "success",
|
||||
"started_at": 1421029603,
|
||||
"finished_at": 1421029813,
|
||||
"message": "Update the Readme",
|
||||
"author": "johnsmith",
|
||||
"author_email": "john.smith@gmail.com"
|
||||
"event": "push",
|
||||
"branch": "master",
|
||||
"commit": "436b7a6e2abaddfd35740527353e78a227ddcb2c",
|
||||
"ref": "refs/heads/master"
|
||||
},
|
||||
"workspace": {
|
||||
"root": "/drone/src",
|
||||
"path": "/drone/src/github.com/drone/drone"
|
||||
},
|
||||
"vargs": {
|
||||
"url": "https://example.rancher.com",
|
||||
"access_key": "1234567abcdefg",
|
||||
"secret_key": "abcdefg1234567",
|
||||
"service": "drone/drone",
|
||||
"docker_image": "drone/drone:latest"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
docker run --rm \
|
||||
-e PLUGIN_URL=<source> \
|
||||
-e PLUGIN_ACCESS_KEY=<key> \
|
||||
-e PLUGIN_SECRET_KEY=<secret> \
|
||||
-e PLUGIN_SERVICE=<service> \
|
||||
-e PLUGIN_DOCKER_IMAGE=<image> \
|
||||
-v $(pwd):$(pwd) \
|
||||
-w $(pwd) \
|
||||
peloton/drone-rancher
|
||||
```
|
||||
|
||||
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
@@ -3,167 +3,106 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/drone/drone-go/plugin"
|
||||
"github.com/rancher/go-rancher/client"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
type Rancher struct {
|
||||
Url string `json:"url"`
|
||||
AccessKey string `json:"access_key"`
|
||||
SecretKey string `json:"secret_key"`
|
||||
Service string `json:"service"`
|
||||
Image string `json:"docker_image"`
|
||||
StartFirst bool `json:"start_first"`
|
||||
Confirm bool `json:"confirm"`
|
||||
Timeout int `json:"timeout"`
|
||||
}
|
||||
|
||||
var (
|
||||
buildCommit string
|
||||
)
|
||||
var build string // build number set at compile-time
|
||||
|
||||
func main() {
|
||||
fmt.Printf("Drone Rancher Plugin built from %s\n", buildCommit)
|
||||
app := cli.NewApp()
|
||||
app.Name = "rancher publish"
|
||||
app.Usage = "rancher publish"
|
||||
app.Action = run
|
||||
app.Version = fmt.Sprintf("1.0.0+%s", build)
|
||||
|
||||
vargs := Rancher{
|
||||
StartFirst: true,
|
||||
Timeout: 30,
|
||||
app.Flags = []cli.Flag{
|
||||
|
||||
cli.StringFlag{
|
||||
Name: "url",
|
||||
Usage: "url to the rancher api",
|
||||
EnvVar: "PLUGIN_URL",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "access-key",
|
||||
Usage: "rancher access key",
|
||||
EnvVar: "PLUGIN_ACCESS_KEY, RANCHER_ACCESS_KEY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "secret-key",
|
||||
Usage: "rancher secret key",
|
||||
EnvVar: "PLUGIN_SECRET_KEY, RANCHER_SECRET_KEY",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "service",
|
||||
Usage: "Service to act on",
|
||||
EnvVar: "PLUGIN_SERVICE",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
Name: "sidekick",
|
||||
Usage: "Service's sidekick name and image separated by the space, supports multiple flags",
|
||||
EnvVar: "PLUGIN_SIDEKICK",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "docker-image",
|
||||
Usage: "image to use",
|
||||
EnvVar: "PLUGIN_DOCKER_IMAGE",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
Name: "start-first",
|
||||
Usage: "Start new container before stoping old",
|
||||
EnvVar: "PLUGIN_START_FIRST",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "confirm",
|
||||
Usage: "auto confirm the service upgrade if successful",
|
||||
EnvVar: "PLUGIN_CONFIRM",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "timeout",
|
||||
Usage: "the maximum wait time in seconds for the service to upgrade",
|
||||
Value: 30,
|
||||
EnvVar: "PLUGIN_TIMEOUT",
|
||||
},
|
||||
cli.Int64Flag{
|
||||
Name: "interval-millis",
|
||||
Usage: "The interval for batch size upgrade",
|
||||
Value: 1000,
|
||||
EnvVar: "PLUGIN_INTERVAL_MILLIS",
|
||||
},
|
||||
cli.Int64Flag{
|
||||
Name: "batch-size",
|
||||
Usage: "The upgrade batch size",
|
||||
Value: 1,
|
||||
EnvVar: "PLUGIN_BATCH_SIZE",
|
||||
},
|
||||
cli.BoolTFlag{
|
||||
Name: "yaml-verified",
|
||||
Usage: "Ensure the yaml was signed",
|
||||
EnvVar: "DRONE_YAML_VERIFIED",
|
||||
},
|
||||
}
|
||||
|
||||
plugin.Param("vargs", &vargs)
|
||||
err := plugin.Parse()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(vargs.Url) == 0 || len(vargs.AccessKey) == 0 || len(vargs.SecretKey) == 0 || len(vargs.Service) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(vargs.Image, "docker:") {
|
||||
vargs.Image = fmt.Sprintf("docker:%s", vargs.Image)
|
||||
}
|
||||
|
||||
var wantedService, wantedStack string
|
||||
if strings.Contains(vargs.Service, "/") {
|
||||
parts := strings.SplitN(vargs.Service, "/", 2)
|
||||
wantedStack = parts[0]
|
||||
wantedService = parts[1]
|
||||
} else {
|
||||
wantedService = vargs.Service
|
||||
}
|
||||
|
||||
rancher, err := client.NewRancherClient(&client.ClientOpts{
|
||||
Url: vargs.Url,
|
||||
AccessKey: vargs.AccessKey,
|
||||
SecretKey: vargs.SecretKey,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to create rancher client: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var stackId string
|
||||
if wantedStack != "" {
|
||||
environments, err := rancher.Environment.List(&client.ListOpts{})
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to list rancher environments: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for _, env := range environments.Data {
|
||||
if env.Name == wantedStack {
|
||||
stackId = env.Id
|
||||
}
|
||||
}
|
||||
|
||||
if stackId == "" {
|
||||
fmt.Printf("Unable to find stack %s\n", wantedStack)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
services, err := rancher.Service.List(&client.ListOpts{})
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to list rancher services: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
found := false
|
||||
var service client.Service
|
||||
for _, svc := range services.Data {
|
||||
if svc.Name == wantedService && ((wantedStack != "" && svc.EnvironmentId == stackId) || wantedStack == "") {
|
||||
service = svc
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
fmt.Printf("Unable to find service %s\n", vargs.Service)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
service.LaunchConfig.ImageUuid = vargs.Image
|
||||
upgrade := &client.ServiceUpgrade{}
|
||||
upgrade.InServiceStrategy = &client.InServiceUpgradeStrategy{
|
||||
LaunchConfig: service.LaunchConfig,
|
||||
SecondaryLaunchConfigs: service.SecondaryLaunchConfigs,
|
||||
StartFirst: vargs.StartFirst,
|
||||
}
|
||||
upgrade.ToServiceStrategy = &client.ToServiceUpgradeStrategy{}
|
||||
|
||||
_, err = rancher.Service.ActionUpgrade(&service, upgrade)
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to upgrade service %s: %s\n", vargs.Service, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Upgraded %s to %s\n", vargs.Service, vargs.Image)
|
||||
|
||||
if vargs.Confirm {
|
||||
srv, err := retry(func() (interface{}, error) {
|
||||
s, e := rancher.Service.ById(service.Id)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
if s.State != "upgraded" {
|
||||
return nil, fmt.Errorf("Service not upgraded: %s", s.State)
|
||||
}
|
||||
return s, nil
|
||||
}, time.Duration(vargs.Timeout)*time.Second, 3*time.Second)
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("Error waiting for service upgrade to complete: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
_, err = rancher.Service.ActionFinishupgrade(srv.(*client.Service))
|
||||
if err != nil {
|
||||
fmt.Printf("Unable to finish upgrade %s: %s\n", vargs.Service, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("Finished upgrade %s\n", vargs.Service)
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
type retryFunc func() (interface{}, error)
|
||||
|
||||
func retry(f retryFunc, timeout time.Duration, interval time.Duration) (interface{}, error) {
|
||||
finish := time.After(timeout)
|
||||
for {
|
||||
result, err := f()
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
select {
|
||||
case <-finish:
|
||||
return nil, err
|
||||
case <-time.After(interval):
|
||||
}
|
||||
func run(c *cli.Context) error {
|
||||
plugin := Plugin{
|
||||
URL: c.String("url"),
|
||||
Key: c.String("access-key"),
|
||||
Secret: c.String("secret-key"),
|
||||
Service: c.String("service"),
|
||||
SidekickDockerImage: c.StringSlice("sidekick"),
|
||||
DockerImage: c.String("docker-image"),
|
||||
StartFirst: c.BoolT("start-first"),
|
||||
Confirm: c.Bool("confirm"),
|
||||
Timeout: c.Int("timeout"),
|
||||
IntervalMillis: c.Int64("interval-millis"),
|
||||
BatchSize: c.Int64("batch-size"),
|
||||
YamlVerified: c.BoolT("yaml-verified"),
|
||||
}
|
||||
return plugin.Exec()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
client "github.com/rancher/go-rancher/v2"
|
||||
)
|
||||
|
||||
type Plugin struct {
|
||||
URL string
|
||||
Key string
|
||||
Secret string
|
||||
Service string
|
||||
SidekickDockerImage []string
|
||||
DockerImage string
|
||||
StartFirst bool
|
||||
Confirm bool
|
||||
Timeout int
|
||||
IntervalMillis int64
|
||||
BatchSize int64
|
||||
YamlVerified bool
|
||||
}
|
||||
|
||||
func (p *Plugin) Exec() error {
|
||||
log.Info("Drone Rancher Plugin built")
|
||||
|
||||
if p.URL == "" || p.Key == "" || p.Secret == "" || p.Service == "" {
|
||||
return errors.New("Eek: Must have url, key, secret, and service definied")
|
||||
}
|
||||
|
||||
var wantedService, wantedStack string
|
||||
if strings.Contains(p.Service, "/") {
|
||||
parts := strings.SplitN(p.Service, "/", 2)
|
||||
wantedStack = parts[0]
|
||||
wantedService = parts[1]
|
||||
} else {
|
||||
wantedService = p.Service
|
||||
}
|
||||
|
||||
rancher, err := client.NewRancherClient(&client.ClientOpts{
|
||||
Url: p.URL,
|
||||
AccessKey: p.Key,
|
||||
SecretKey: p.Secret,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to create rancher client: %s", err)
|
||||
}
|
||||
|
||||
// Prepare service filters for service listing
|
||||
serviceFilters := map[string]interface{}{"name": wantedService}
|
||||
|
||||
// Query stacks with filter name=wantedStack
|
||||
if wantedStack != "" {
|
||||
stacks, err := rancher.Stack.List(&client.ListOpts{Filters: map[string]interface{}{"name": wantedStack}})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to list rancher environments: %s", err)
|
||||
}
|
||||
if len(stacks.Data) <= 0 {
|
||||
return fmt.Errorf("Unable to find stack %s", wantedStack)
|
||||
}
|
||||
// If found add stackID to serviceFilters
|
||||
serviceFilters["stackId"] = stacks.Data[0].Id
|
||||
|
||||
}
|
||||
|
||||
// Query services with prepared filters
|
||||
services, err := rancher.Service.List(&client.ListOpts{Filters: serviceFilters})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to list rancher services: %s", err)
|
||||
}
|
||||
if len(services.Data) <= 0 {
|
||||
return fmt.Errorf("Unable to find service %s", p.Service)
|
||||
}
|
||||
service := services.Data[0]
|
||||
// Service is found, proceed with upgrade
|
||||
|
||||
// We want to exit if there is no docker image updates
|
||||
if p.DockerImage == "" && len(p.SidekickDockerImage) <= 0 {
|
||||
return fmt.Errorf("Nothing to upgrade")
|
||||
}
|
||||
|
||||
// Only change value if it's not null.
|
||||
if p.DockerImage != "" {
|
||||
// Add prefix when missing to meet Rancher API requirement
|
||||
service.LaunchConfig.ImageUuid = prepareDockerPrefix(p.DockerImage)
|
||||
}
|
||||
|
||||
// Iterate over provided sidekick flags
|
||||
for _, sidekick := range p.SidekickDockerImage {
|
||||
// Split flag in two from "--sidekick nginx nginx:latest"
|
||||
parts := strings.SplitN(sidekick, " ", 2)
|
||||
wantedSidekick := parts[0]
|
||||
wantedImage := parts[1]
|
||||
for i, s := range service.SecondaryLaunchConfigs {
|
||||
if wantedSidekick == s.Name {
|
||||
service.SecondaryLaunchConfigs[i].ImageUuid = prepareDockerPrefix(wantedImage)
|
||||
}
|
||||
}
|
||||
}
|
||||
upgrade := &client.ServiceUpgrade{}
|
||||
upgrade.InServiceStrategy = &client.InServiceUpgradeStrategy{
|
||||
LaunchConfig: service.LaunchConfig,
|
||||
SecondaryLaunchConfigs: service.SecondaryLaunchConfigs,
|
||||
StartFirst: p.StartFirst,
|
||||
IntervalMillis: p.IntervalMillis,
|
||||
BatchSize: p.BatchSize,
|
||||
}
|
||||
upgrade.ToServiceStrategy = &client.ToServiceUpgradeStrategy{}
|
||||
_, err = rancher.Service.ActionUpgrade(&service, upgrade)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to upgrade service %s: %s", p.Service, err)
|
||||
}
|
||||
|
||||
if p.Confirm {
|
||||
srv, err := retry(func() (interface{}, error) {
|
||||
s, e := rancher.Service.ById(service.Id)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
if s.State != "upgraded" {
|
||||
return nil, fmt.Errorf("Service not upgraded: %s", s.State)
|
||||
}
|
||||
return s, nil
|
||||
}, time.Duration(p.Timeout)*time.Second, 3*time.Second)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error waiting for service upgrade to complete: %s", err)
|
||||
}
|
||||
|
||||
_, err = rancher.Service.ActionFinishupgrade(srv.(*client.Service))
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to finish upgrade %s: %s", p.Service, err)
|
||||
}
|
||||
log.Infof("Finished upgrade %s", p.Service)
|
||||
}
|
||||
|
||||
log.Infof("Upgraded %s to %s", p.Service, p.DockerImage)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type retryFunc func() (interface{}, error)
|
||||
|
||||
func prepareDockerPrefix(image string) string {
|
||||
if !strings.HasPrefix(image, "docker:") {
|
||||
image = fmt.Sprintf("docker:%s", image)
|
||||
}
|
||||
return image
|
||||
}
|
||||
|
||||
func retry(f retryFunc, timeout time.Duration, interval time.Duration) (interface{}, error) {
|
||||
finish := time.After(timeout)
|
||||
for {
|
||||
result, err := f()
|
||||
if err == nil {
|
||||
return result, nil
|
||||
}
|
||||
select {
|
||||
case <-finish:
|
||||
return nil, err
|
||||
case <-time.After(interval):
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
vendors:
|
||||
- path: github.com/drone/drone-go
|
||||
rev: eaa41f7836a191224ec5702d2458db07882ec269
|
||||
- path: github.com/gorilla/websocket
|
||||
rev: a68708917c6a4f06314ab4e52493cc61359c9d42
|
||||
- path: github.com/rancher/go-rancher
|
||||
rev: 6f68a5fa617dca7db1a509c2a789c1fffaca7b19
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
# 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
@@ -0,0 +1,21 @@
|
||||
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
@@ -0,0 +1,388 @@
|
||||
# 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
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
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
@@ -0,0 +1,264 @@
|
||||
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
@@ -0,0 +1,193 @@
|
||||
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
@@ -0,0 +1,48 @@
|
||||
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
@@ -0,0 +1,34 @@
|
||||
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
@@ -0,0 +1,41 @@
|
||||
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
@@ -0,0 +1,212 @@
|
||||
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
@@ -0,0 +1,143 @@
|
||||
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
@@ -0,0 +1,9 @@
|
||||
// +build darwin freebsd openbsd netbsd dragonfly
|
||||
|
||||
package logrus
|
||||
|
||||
import "syscall"
|
||||
|
||||
const ioctlReadTermios = syscall.TIOCGETA
|
||||
|
||||
type Termios syscall.Termios
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// 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
@@ -0,0 +1,21 @@
|
||||
// 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
@@ -0,0 +1,15 @@
|
||||
// +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
@@ -0,0 +1,27 @@
|
||||
// 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
@@ -0,0 +1,161 @@
|
||||
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
@@ -0,0 +1,31 @@
|
||||
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()
|
||||
}
|
||||
-202
@@ -1,202 +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
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
# drone-go
|
||||
|
||||
[](http://beta.drone.io/drone/drone-go)
|
||||
|
||||
drone-go is a Go client library for accessing the Drone [API](http://readme.drone.io/devs/api/builds/) and writing [plugins](http://readme.drone.io/plugins/).
|
||||
|
||||
Download the package using `go get`:
|
||||
|
||||
```Go
|
||||
go get "github.com/drone/drone-go/drone"
|
||||
go get "github.com/drone/drone-go/plugin"
|
||||
```
|
||||
|
||||
Import the package:
|
||||
|
||||
```Go
|
||||
import "github.com/drone/drone-go/drone"
|
||||
```
|
||||
|
||||
Create the client:
|
||||
|
||||
```Go
|
||||
const (
|
||||
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
|
||||
host = "http://drone.company.com"
|
||||
)
|
||||
|
||||
client := drone.NewClientToken(host, token)
|
||||
```
|
||||
|
||||
Get the current user:
|
||||
|
||||
```Go
|
||||
user, err := client.Self()
|
||||
fmt.Println(user)
|
||||
```
|
||||
|
||||
Get the repository list:
|
||||
|
||||
```Go
|
||||
repos, err := client.RepoList()
|
||||
fmt.Println(repos)
|
||||
```
|
||||
|
||||
Get the named repository:
|
||||
|
||||
```Go
|
||||
repo, err := client.Repo("drone", "drone-go")
|
||||
fmt.Println(repo)
|
||||
```
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// Standard Input
|
||||
var Stdin *ParamSet
|
||||
|
||||
func init() {
|
||||
// defaults to stdin
|
||||
Stdin = NewParamSet(os.Stdin)
|
||||
|
||||
// check for params after the double dash
|
||||
// in the command string
|
||||
for i, argv := range os.Args {
|
||||
if argv == "--" {
|
||||
arg := os.Args[i+1]
|
||||
buf := bytes.NewBufferString(arg)
|
||||
Stdin = NewParamSet(buf)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this init function is deprecated, but I'm keeping it
|
||||
// around just in case it proves useful in the future.
|
||||
func deprecated_init() {
|
||||
// if piping from stdin we can just exit
|
||||
// and use the default Stdin value
|
||||
stat, _ := os.Stdin.Stat()
|
||||
if (stat.Mode() & os.ModeCharDevice) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// check for params after the double dash
|
||||
// in the command string
|
||||
for i, argv := range os.Args {
|
||||
if argv == "--" {
|
||||
arg := os.Args[i+1]
|
||||
buf := bytes.NewBufferString(arg)
|
||||
Stdin = NewParamSet(buf)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// else use the first variable in the list
|
||||
if len(os.Args) > 1 {
|
||||
buf := bytes.NewBufferString(os.Args[1])
|
||||
Stdin = NewParamSet(buf)
|
||||
}
|
||||
}
|
||||
|
||||
// ParamSet describes a parameter set.
|
||||
type ParamSet struct {
|
||||
reader io.Reader
|
||||
params map[string]interface{}
|
||||
}
|
||||
|
||||
// NewParamSet takes a io.Reader and returns a ParamSet.
|
||||
func NewParamSet(reader io.Reader) *ParamSet {
|
||||
var p = new(ParamSet)
|
||||
p.reader = reader
|
||||
p.params = map[string]interface{}{}
|
||||
return p
|
||||
}
|
||||
|
||||
// Param defines a parameter with the specified name.
|
||||
func (p ParamSet) Param(name string, value interface{}) {
|
||||
p.params[name] = value
|
||||
}
|
||||
|
||||
// Parse parses parameter definitions from the map.
|
||||
func (p ParamSet) Parse() error {
|
||||
raw := map[string]json.RawMessage{}
|
||||
err := json.NewDecoder(p.reader).Decode(&raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for key, val := range p.params {
|
||||
data, ok := raw[key]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
err := json.Unmarshal(data, val)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to unarmshal %s. %s", key, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Unmarshal parses the JSON payload from the command
|
||||
// arguments and unmarshal into a value pointed to by v.
|
||||
func (p ParamSet) Unmarshal(v interface{}) error {
|
||||
return json.NewDecoder(p.reader).Decode(v)
|
||||
}
|
||||
|
||||
// Param defines a parameter with the specified name.
|
||||
func Param(name string, value interface{}) {
|
||||
Stdin.Param(name, value)
|
||||
}
|
||||
|
||||
// Parse parses parameter definitions from the map.
|
||||
func Parse() error {
|
||||
return Stdin.Parse()
|
||||
}
|
||||
|
||||
// Unmarshal parses the JSON payload from the command
|
||||
// arguments and unmarshal into a value pointed to by v.
|
||||
func Unmarshal(v interface{}) error {
|
||||
return Stdin.Unmarshal(v)
|
||||
}
|
||||
|
||||
// MustUnmarshal parses the JSON payload from the command
|
||||
// arguments and unmarshal into a value pointed to by v.
|
||||
func MustUnmarshal(v interface{}) error {
|
||||
return Stdin.Unmarshal(v)
|
||||
}
|
||||
|
||||
// MustParse parses parameter definitions from the map
|
||||
// and panics if there is a parsing error.
|
||||
func MustParse() {
|
||||
err := Parse()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -3,6 +3,9 @@
|
||||
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)
|
||||
@@ -43,7 +46,7 @@ subdirectory](https://github.com/gorilla/websocket/tree/master/examples/autobahn
|
||||
<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>Limit size of received message</td><td><a href="http://godoc.org/github.com/gorilla/websocket#Conn.SetReadLimit">Yes</a></td><td><a href="https://code.google.com/p/go/issues/detail?id=5082">No</a></td></tr>
|
||||
<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>
|
||||
|
||||
+49
-32
@@ -23,6 +23,8 @@ import (
|
||||
// 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
|
||||
@@ -64,12 +66,24 @@ type Dialer struct {
|
||||
// HandshakeTimeout specifies the duration for the handshake to complete.
|
||||
HandshakeTimeout time.Duration
|
||||
|
||||
// Input and output buffer sizes. If the buffer size is zero, then a
|
||||
// default value of 4096 is used.
|
||||
// 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")
|
||||
@@ -83,7 +97,6 @@ func parseURL(s string) (*url.URL, error) {
|
||||
//
|
||||
// ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
|
||||
// wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]
|
||||
|
||||
var u url.URL
|
||||
switch {
|
||||
case strings.HasPrefix(s, "ws://"):
|
||||
@@ -193,6 +206,13 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
||||
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
|
||||
@@ -214,6 +234,7 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
||||
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:
|
||||
@@ -221,6 +242,10 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@@ -324,6 +349,13 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
||||
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") ||
|
||||
@@ -337,6 +369,20 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
||||
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")
|
||||
|
||||
@@ -344,32 +390,3 @@ func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Re
|
||||
netConn = nil // to avoid close in defer.
|
||||
return conn, resp, nil
|
||||
}
|
||||
|
||||
// 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,
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// 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
@@ -0,0 +1,38 @@
|
||||
// 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
@@ -0,0 +1,148 @@
|
||||
// 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
|
||||
}
|
||||
+343
-145
@@ -13,16 +13,25 @@ import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
const (
|
||||
// Frame header byte 0 bits from Section 5.2 of RFC 6455
|
||||
finalBit = 1 << 7
|
||||
rsv1Bit = 1 << 6
|
||||
rsv2Bit = 1 << 5
|
||||
rsv3Bit = 1 << 4
|
||||
|
||||
// Frame header byte 1 bits from Section 5.2 of RFC 6455
|
||||
maskBit = 1 << 7
|
||||
|
||||
maxFrameHeaderSize = 2 + 8 + 4 // Fixed header + length + mask
|
||||
maxControlFramePayloadSize = 125
|
||||
finalBit = 1 << 7
|
||||
maskBit = 1 << 7
|
||||
writeWait = time.Second
|
||||
|
||||
writeWait = time.Second
|
||||
|
||||
defaultReadBufferSize = 4096
|
||||
defaultWriteBufferSize = 4096
|
||||
@@ -172,6 +181,11 @@ var (
|
||||
errInvalidControlFrame = errors.New("websocket: invalid control frame")
|
||||
)
|
||||
|
||||
func newMaskKey() [4]byte {
|
||||
n := rand.Uint32()
|
||||
return [4]byte{byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24)}
|
||||
}
|
||||
|
||||
func hideTempErr(err error) error {
|
||||
if e, ok := err.(net.Error); ok && e.Temporary() {
|
||||
err = &netError{msg: e.Error(), timeout: e.Timeout()}
|
||||
@@ -210,39 +224,28 @@ func isValidReceivedCloseCode(code int) bool {
|
||||
return validReceivedCloseCodes[code] || (code >= 3000 && code <= 4999)
|
||||
}
|
||||
|
||||
func maskBytes(key [4]byte, pos int, b []byte) int {
|
||||
for i := range b {
|
||||
b[i] ^= key[pos&3]
|
||||
pos++
|
||||
}
|
||||
return pos & 3
|
||||
}
|
||||
|
||||
func newMaskKey() [4]byte {
|
||||
n := rand.Uint32()
|
||||
return [4]byte{byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24)}
|
||||
}
|
||||
|
||||
// Conn represents a WebSocket connection.
|
||||
// The Conn type represents a WebSocket connection.
|
||||
type Conn struct {
|
||||
conn net.Conn
|
||||
isServer bool
|
||||
subprotocol string
|
||||
|
||||
// Write fields
|
||||
mu chan bool // used as mutex to protect write to conn and closeSent
|
||||
closeSent bool // true if close message was sent
|
||||
mu chan bool // used as mutex to protect write to conn
|
||||
writeBuf []byte // frame is constructed in this buffer.
|
||||
writeDeadline time.Time
|
||||
writer io.WriteCloser // the current writer returned to the application
|
||||
isWriting bool // for best-effort concurrent write detection
|
||||
|
||||
// Message writer fields.
|
||||
writeErr error
|
||||
writeBuf []byte // frame is constructed in this buffer.
|
||||
writePos int // end of data in writeBuf.
|
||||
writeFrameType int // type of the current frame.
|
||||
writeDeadline time.Time
|
||||
isWriting bool // for best-effort concurrent write detection
|
||||
messageWriter *messageWriter // the current writer
|
||||
writeErrMu sync.Mutex
|
||||
writeErr error
|
||||
|
||||
enableWriteCompression bool
|
||||
compressionLevel int
|
||||
newCompressionWriter func(io.WriteCloser, int) io.WriteCloser
|
||||
|
||||
// Read fields
|
||||
reader io.ReadCloser // the current reader returned to the application
|
||||
readErr error
|
||||
br *bufio.Reader
|
||||
readRemaining int64 // bytes remaining in current frame.
|
||||
@@ -253,34 +256,83 @@ type Conn struct {
|
||||
readMaskKey [4]byte
|
||||
handlePong func(string) error
|
||||
handlePing func(string) error
|
||||
handleClose func(int, string) error
|
||||
readErrCount int
|
||||
messageReader *messageReader // the current reader
|
||||
messageReader *messageReader // the current low-level reader
|
||||
|
||||
readDecompress bool // whether last read frame had RSV1 set
|
||||
newDecompressionReader func(io.Reader) io.ReadCloser
|
||||
}
|
||||
|
||||
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn {
|
||||
return newConnBRW(conn, isServer, readBufferSize, writeBufferSize, nil)
|
||||
}
|
||||
|
||||
type writeHook struct {
|
||||
p []byte
|
||||
}
|
||||
|
||||
func (wh *writeHook) Write(p []byte) (int, error) {
|
||||
wh.p = p
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func newConnBRW(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, brw *bufio.ReadWriter) *Conn {
|
||||
mu := make(chan bool, 1)
|
||||
mu <- true
|
||||
|
||||
if readBufferSize == 0 {
|
||||
readBufferSize = defaultReadBufferSize
|
||||
var br *bufio.Reader
|
||||
if readBufferSize == 0 && brw != nil && brw.Reader != nil {
|
||||
// Reuse the supplied bufio.Reader if the buffer has a useful size.
|
||||
// This code assumes that peek on a reader returns
|
||||
// bufio.Reader.buf[:0].
|
||||
brw.Reader.Reset(conn)
|
||||
if p, err := brw.Reader.Peek(0); err == nil && cap(p) >= 256 {
|
||||
br = brw.Reader
|
||||
}
|
||||
}
|
||||
if readBufferSize < maxControlFramePayloadSize {
|
||||
readBufferSize = maxControlFramePayloadSize
|
||||
if br == nil {
|
||||
if readBufferSize == 0 {
|
||||
readBufferSize = defaultReadBufferSize
|
||||
}
|
||||
if readBufferSize < maxControlFramePayloadSize {
|
||||
readBufferSize = maxControlFramePayloadSize
|
||||
}
|
||||
br = bufio.NewReaderSize(conn, readBufferSize)
|
||||
}
|
||||
if writeBufferSize == 0 {
|
||||
writeBufferSize = defaultWriteBufferSize
|
||||
|
||||
var writeBuf []byte
|
||||
if writeBufferSize == 0 && brw != nil && brw.Writer != nil {
|
||||
// Use the bufio.Writer's buffer if the buffer has a useful size. This
|
||||
// code assumes that bufio.Writer.buf[:1] is passed to the
|
||||
// bufio.Writer's underlying writer.
|
||||
var wh writeHook
|
||||
brw.Writer.Reset(&wh)
|
||||
brw.Writer.WriteByte(0)
|
||||
brw.Flush()
|
||||
if cap(wh.p) >= maxFrameHeaderSize+256 {
|
||||
writeBuf = wh.p[:cap(wh.p)]
|
||||
}
|
||||
}
|
||||
|
||||
if writeBuf == nil {
|
||||
if writeBufferSize == 0 {
|
||||
writeBufferSize = defaultWriteBufferSize
|
||||
}
|
||||
writeBuf = make([]byte, writeBufferSize+maxFrameHeaderSize)
|
||||
}
|
||||
|
||||
c := &Conn{
|
||||
isServer: isServer,
|
||||
br: bufio.NewReaderSize(conn, readBufferSize),
|
||||
conn: conn,
|
||||
mu: mu,
|
||||
readFinal: true,
|
||||
writeBuf: make([]byte, writeBufferSize+maxFrameHeaderSize),
|
||||
writeFrameType: noFrame,
|
||||
writePos: maxFrameHeaderSize,
|
||||
isServer: isServer,
|
||||
br: br,
|
||||
conn: conn,
|
||||
mu: mu,
|
||||
readFinal: true,
|
||||
writeBuf: writeBuf,
|
||||
enableWriteCompression: true,
|
||||
compressionLevel: defaultCompressionLevel,
|
||||
}
|
||||
c.SetCloseHandler(nil)
|
||||
c.SetPingHandler(nil)
|
||||
c.SetPongHandler(nil)
|
||||
return c
|
||||
@@ -308,29 +360,40 @@ func (c *Conn) RemoteAddr() net.Addr {
|
||||
|
||||
// Write methods
|
||||
|
||||
func (c *Conn) writeFatal(err error) error {
|
||||
err = hideTempErr(err)
|
||||
c.writeErrMu.Lock()
|
||||
if c.writeErr == nil {
|
||||
c.writeErr = err
|
||||
}
|
||||
c.writeErrMu.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Conn) write(frameType int, deadline time.Time, bufs ...[]byte) error {
|
||||
<-c.mu
|
||||
defer func() { c.mu <- true }()
|
||||
|
||||
if c.closeSent {
|
||||
return ErrCloseSent
|
||||
} else if frameType == CloseMessage {
|
||||
c.closeSent = true
|
||||
c.writeErrMu.Lock()
|
||||
err := c.writeErr
|
||||
c.writeErrMu.Unlock()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.conn.SetWriteDeadline(deadline)
|
||||
for _, buf := range bufs {
|
||||
if len(buf) > 0 {
|
||||
n, err := c.conn.Write(buf)
|
||||
if n != len(buf) {
|
||||
// Close on partial write.
|
||||
c.conn.Close()
|
||||
}
|
||||
_, err := c.conn.Write(buf)
|
||||
if err != nil {
|
||||
return err
|
||||
return c.writeFatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if frameType == CloseMessage {
|
||||
c.writeFatal(ErrCloseSent)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -379,18 +442,41 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er
|
||||
}
|
||||
defer func() { c.mu <- true }()
|
||||
|
||||
if c.closeSent {
|
||||
return ErrCloseSent
|
||||
} else if messageType == CloseMessage {
|
||||
c.closeSent = true
|
||||
c.writeErrMu.Lock()
|
||||
err := c.writeErr
|
||||
c.writeErrMu.Unlock()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.conn.SetWriteDeadline(deadline)
|
||||
n, err := c.conn.Write(buf)
|
||||
if n != 0 && n != len(buf) {
|
||||
c.conn.Close()
|
||||
_, err = c.conn.Write(buf)
|
||||
if err != nil {
|
||||
return c.writeFatal(err)
|
||||
}
|
||||
return hideTempErr(err)
|
||||
if messageType == CloseMessage {
|
||||
c.writeFatal(ErrCloseSent)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Conn) prepWrite(messageType int) error {
|
||||
// Close previous writer if not already closed by the application. It's
|
||||
// probably better to return an error in this situation, but we cannot
|
||||
// change this without breaking existing applications.
|
||||
if c.writer != nil {
|
||||
c.writer.Close()
|
||||
c.writer = nil
|
||||
}
|
||||
|
||||
if !isControl(messageType) && !isData(messageType) {
|
||||
return errBadWriteOpCode
|
||||
}
|
||||
|
||||
c.writeErrMu.Lock()
|
||||
err := c.writeErr
|
||||
c.writeErrMu.Unlock()
|
||||
return err
|
||||
}
|
||||
|
||||
// NextWriter returns a writer for the next message to send. The writer's Close
|
||||
@@ -399,42 +485,61 @@ func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) er
|
||||
// There can be at most one open writer on a connection. NextWriter closes the
|
||||
// previous writer if the application has not already done so.
|
||||
func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) {
|
||||
if c.writeErr != nil {
|
||||
return nil, c.writeErr
|
||||
if err := c.prepWrite(messageType); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if c.writeFrameType != noFrame {
|
||||
if err := c.flushFrame(true, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mw := &messageWriter{
|
||||
c: c,
|
||||
frameType: messageType,
|
||||
pos: maxFrameHeaderSize,
|
||||
}
|
||||
|
||||
if !isControl(messageType) && !isData(messageType) {
|
||||
return nil, errBadWriteOpCode
|
||||
c.writer = mw
|
||||
if c.newCompressionWriter != nil && c.enableWriteCompression && isData(messageType) {
|
||||
w := c.newCompressionWriter(c.writer, c.compressionLevel)
|
||||
mw.compress = true
|
||||
c.writer = w
|
||||
}
|
||||
|
||||
c.writeFrameType = messageType
|
||||
w := &messageWriter{c}
|
||||
c.messageWriter = w
|
||||
return w, nil
|
||||
return c.writer, nil
|
||||
}
|
||||
|
||||
func (c *Conn) flushFrame(final bool, extra []byte) error {
|
||||
length := c.writePos - maxFrameHeaderSize + len(extra)
|
||||
type messageWriter struct {
|
||||
c *Conn
|
||||
compress bool // whether next call to flushFrame should set RSV1
|
||||
pos int // end of data in writeBuf.
|
||||
frameType int // type of the current frame.
|
||||
err error
|
||||
}
|
||||
|
||||
func (w *messageWriter) fatal(err error) error {
|
||||
if w.err != nil {
|
||||
w.err = err
|
||||
w.c.writer = nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// flushFrame writes buffered data and extra as a frame to the network. The
|
||||
// final argument indicates that this is the last frame in the message.
|
||||
func (w *messageWriter) flushFrame(final bool, extra []byte) error {
|
||||
c := w.c
|
||||
length := w.pos - maxFrameHeaderSize + len(extra)
|
||||
|
||||
// Check for invalid control frames.
|
||||
if isControl(c.writeFrameType) &&
|
||||
if isControl(w.frameType) &&
|
||||
(!final || length > maxControlFramePayloadSize) {
|
||||
c.messageWriter = nil
|
||||
c.writeFrameType = noFrame
|
||||
c.writePos = maxFrameHeaderSize
|
||||
return errInvalidControlFrame
|
||||
return w.fatal(errInvalidControlFrame)
|
||||
}
|
||||
|
||||
b0 := byte(c.writeFrameType)
|
||||
b0 := byte(w.frameType)
|
||||
if final {
|
||||
b0 |= finalBit
|
||||
}
|
||||
if w.compress {
|
||||
b0 |= rsv1Bit
|
||||
}
|
||||
w.compress = false
|
||||
|
||||
b1 := byte(0)
|
||||
if !c.isServer {
|
||||
b1 |= maskBit
|
||||
@@ -466,10 +571,9 @@ func (c *Conn) flushFrame(final bool, extra []byte) error {
|
||||
if !c.isServer {
|
||||
key := newMaskKey()
|
||||
copy(c.writeBuf[maxFrameHeaderSize-4:], key[:])
|
||||
maskBytes(key, 0, c.writeBuf[maxFrameHeaderSize:c.writePos])
|
||||
maskBytes(key, 0, c.writeBuf[maxFrameHeaderSize:w.pos])
|
||||
if len(extra) > 0 {
|
||||
c.writeErr = errors.New("websocket: internal error, extra used in client mode")
|
||||
return c.writeErr
|
||||
return c.writeFatal(errors.New("websocket: internal error, extra used in client mode"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,43 +586,35 @@ func (c *Conn) flushFrame(final bool, extra []byte) error {
|
||||
}
|
||||
c.isWriting = true
|
||||
|
||||
c.writeErr = c.write(c.writeFrameType, c.writeDeadline, c.writeBuf[framePos:c.writePos], extra)
|
||||
err := c.write(w.frameType, c.writeDeadline, c.writeBuf[framePos:w.pos], extra)
|
||||
|
||||
if !c.isWriting {
|
||||
panic("concurrent write to websocket connection")
|
||||
}
|
||||
c.isWriting = false
|
||||
|
||||
// Setup for next frame.
|
||||
c.writePos = maxFrameHeaderSize
|
||||
c.writeFrameType = continuationFrame
|
||||
if err != nil {
|
||||
return w.fatal(err)
|
||||
}
|
||||
|
||||
if final {
|
||||
c.messageWriter = nil
|
||||
c.writeFrameType = noFrame
|
||||
c.writer = nil
|
||||
return nil
|
||||
}
|
||||
return c.writeErr
|
||||
}
|
||||
|
||||
type messageWriter struct{ c *Conn }
|
||||
|
||||
func (w *messageWriter) err() error {
|
||||
c := w.c
|
||||
if c.messageWriter != w {
|
||||
return errWriteClosed
|
||||
}
|
||||
if c.writeErr != nil {
|
||||
return c.writeErr
|
||||
}
|
||||
// Setup for next frame.
|
||||
w.pos = maxFrameHeaderSize
|
||||
w.frameType = continuationFrame
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *messageWriter) ncopy(max int) (int, error) {
|
||||
n := len(w.c.writeBuf) - w.c.writePos
|
||||
n := len(w.c.writeBuf) - w.pos
|
||||
if n <= 0 {
|
||||
if err := w.c.flushFrame(false, nil); err != nil {
|
||||
if err := w.flushFrame(false, nil); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
n = len(w.c.writeBuf) - w.c.writePos
|
||||
n = len(w.c.writeBuf) - w.pos
|
||||
}
|
||||
if n > max {
|
||||
n = max
|
||||
@@ -526,14 +622,14 @@ func (w *messageWriter) ncopy(max int) (int, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (w *messageWriter) write(final bool, p []byte) (int, error) {
|
||||
if err := w.err(); err != nil {
|
||||
return 0, err
|
||||
func (w *messageWriter) Write(p []byte) (int, error) {
|
||||
if w.err != nil {
|
||||
return 0, w.err
|
||||
}
|
||||
|
||||
if len(p) > 2*len(w.c.writeBuf) && w.c.isServer {
|
||||
// Don't buffer large messages.
|
||||
err := w.c.flushFrame(final, p)
|
||||
err := w.flushFrame(false, p)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -546,20 +642,16 @@ func (w *messageWriter) write(final bool, p []byte) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
copy(w.c.writeBuf[w.c.writePos:], p[:n])
|
||||
w.c.writePos += n
|
||||
copy(w.c.writeBuf[w.pos:], p[:n])
|
||||
w.pos += n
|
||||
p = p[n:]
|
||||
}
|
||||
return nn, nil
|
||||
}
|
||||
|
||||
func (w *messageWriter) Write(p []byte) (int, error) {
|
||||
return w.write(false, p)
|
||||
}
|
||||
|
||||
func (w *messageWriter) WriteString(p string) (int, error) {
|
||||
if err := w.err(); err != nil {
|
||||
return 0, err
|
||||
if w.err != nil {
|
||||
return 0, w.err
|
||||
}
|
||||
|
||||
nn := len(p)
|
||||
@@ -568,27 +660,27 @@ func (w *messageWriter) WriteString(p string) (int, error) {
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
copy(w.c.writeBuf[w.c.writePos:], p[:n])
|
||||
w.c.writePos += n
|
||||
copy(w.c.writeBuf[w.pos:], p[:n])
|
||||
w.pos += n
|
||||
p = p[n:]
|
||||
}
|
||||
return nn, nil
|
||||
}
|
||||
|
||||
func (w *messageWriter) ReadFrom(r io.Reader) (nn int64, err error) {
|
||||
if err := w.err(); err != nil {
|
||||
return 0, err
|
||||
if w.err != nil {
|
||||
return 0, w.err
|
||||
}
|
||||
for {
|
||||
if w.c.writePos == len(w.c.writeBuf) {
|
||||
err = w.c.flushFrame(false, nil)
|
||||
if w.pos == len(w.c.writeBuf) {
|
||||
err = w.flushFrame(false, nil)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
var n int
|
||||
n, err = r.Read(w.c.writeBuf[w.c.writePos:])
|
||||
w.c.writePos += n
|
||||
n, err = r.Read(w.c.writeBuf[w.pos:])
|
||||
w.pos += n
|
||||
nn += int64(n)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
@@ -601,27 +693,59 @@ func (w *messageWriter) ReadFrom(r io.Reader) (nn int64, err error) {
|
||||
}
|
||||
|
||||
func (w *messageWriter) Close() error {
|
||||
if err := w.err(); err != nil {
|
||||
if w.err != nil {
|
||||
return w.err
|
||||
}
|
||||
if err := w.flushFrame(true, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
return w.c.flushFrame(true, nil)
|
||||
w.err = errWriteClosed
|
||||
return nil
|
||||
}
|
||||
|
||||
// WritePreparedMessage writes prepared message into connection.
|
||||
func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error {
|
||||
frameType, frameData, err := pm.frame(prepareKey{
|
||||
isServer: c.isServer,
|
||||
compress: c.newCompressionWriter != nil && c.enableWriteCompression && isData(pm.messageType),
|
||||
compressionLevel: c.compressionLevel,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if c.isWriting {
|
||||
panic("concurrent write to websocket connection")
|
||||
}
|
||||
c.isWriting = true
|
||||
err = c.write(frameType, c.writeDeadline, frameData, nil)
|
||||
if !c.isWriting {
|
||||
panic("concurrent write to websocket connection")
|
||||
}
|
||||
c.isWriting = false
|
||||
return err
|
||||
}
|
||||
|
||||
// WriteMessage is a helper method for getting a writer using NextWriter,
|
||||
// writing the message and closing the writer.
|
||||
func (c *Conn) WriteMessage(messageType int, data []byte) error {
|
||||
|
||||
if c.isServer && (c.newCompressionWriter == nil || !c.enableWriteCompression) {
|
||||
// Fast path with no allocations and single frame.
|
||||
|
||||
if err := c.prepWrite(messageType); err != nil {
|
||||
return err
|
||||
}
|
||||
mw := messageWriter{c: c, frameType: messageType, pos: maxFrameHeaderSize}
|
||||
n := copy(c.writeBuf[mw.pos:], data)
|
||||
mw.pos += n
|
||||
data = data[n:]
|
||||
return mw.flushFrame(true, data)
|
||||
}
|
||||
|
||||
w, err := c.NextWriter(messageType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, ok := w.(*messageWriter); ok && c.isServer {
|
||||
// Optimize write as a single frame.
|
||||
n := copy(c.writeBuf[c.writePos:], data)
|
||||
c.writePos += n
|
||||
data = data[n:]
|
||||
err = c.flushFrame(true, data)
|
||||
return err
|
||||
}
|
||||
if _, err = w.Write(data); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -658,12 +782,17 @@ func (c *Conn) advanceFrame() (int, error) {
|
||||
|
||||
final := p[0]&finalBit != 0
|
||||
frameType := int(p[0] & 0xf)
|
||||
reserved := int((p[0] >> 4) & 0x7)
|
||||
mask := p[1]&maskBit != 0
|
||||
c.readRemaining = int64(p[1] & 0x7f)
|
||||
|
||||
if reserved != 0 {
|
||||
return noFrame, c.handleProtocolError("unexpected reserved bits " + strconv.Itoa(reserved))
|
||||
c.readDecompress = false
|
||||
if c.newDecompressionReader != nil && (p[0]&rsv1Bit) != 0 {
|
||||
c.readDecompress = true
|
||||
p[0] &^= rsv1Bit
|
||||
}
|
||||
|
||||
if rsv := p[0] & (rsv1Bit | rsv2Bit | rsv3Bit); rsv != 0 {
|
||||
return noFrame, c.handleProtocolError("unexpected reserved bits 0x" + strconv.FormatInt(int64(rsv), 16))
|
||||
}
|
||||
|
||||
switch frameType {
|
||||
@@ -759,11 +888,9 @@ func (c *Conn) advanceFrame() (int, error) {
|
||||
return noFrame, err
|
||||
}
|
||||
case CloseMessage:
|
||||
echoMessage := []byte{}
|
||||
closeCode := CloseNoStatusReceived
|
||||
closeText := ""
|
||||
if len(payload) >= 2 {
|
||||
echoMessage = payload[:2]
|
||||
closeCode = int(binary.BigEndian.Uint16(payload))
|
||||
if !isValidReceivedCloseCode(closeCode) {
|
||||
return noFrame, c.handleProtocolError("invalid close code")
|
||||
@@ -773,7 +900,9 @@ func (c *Conn) advanceFrame() (int, error) {
|
||||
return noFrame, c.handleProtocolError("invalid utf8 payload in close frame")
|
||||
}
|
||||
}
|
||||
c.WriteControl(CloseMessage, echoMessage, time.Now().Add(writeWait))
|
||||
if err := c.handleClose(closeCode, closeText); err != nil {
|
||||
return noFrame, err
|
||||
}
|
||||
return noFrame, &CloseError{Code: closeCode, Text: closeText}
|
||||
}
|
||||
|
||||
@@ -796,6 +925,11 @@ func (c *Conn) handleProtocolError(message string) error {
|
||||
// permanent. Once this method returns a non-nil error, all subsequent calls to
|
||||
// this method return the same error.
|
||||
func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
|
||||
// Close previous reader, only relevant for decompression.
|
||||
if c.reader != nil {
|
||||
c.reader.Close()
|
||||
c.reader = nil
|
||||
}
|
||||
|
||||
c.messageReader = nil
|
||||
c.readLength = 0
|
||||
@@ -807,9 +941,12 @@ func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
|
||||
break
|
||||
}
|
||||
if frameType == TextMessage || frameType == BinaryMessage {
|
||||
r := &messageReader{c}
|
||||
c.messageReader = r
|
||||
return frameType, r, nil
|
||||
c.messageReader = &messageReader{c}
|
||||
c.reader = c.messageReader
|
||||
if c.readDecompress {
|
||||
c.reader = c.newDecompressionReader(c.reader)
|
||||
}
|
||||
return frameType, c.reader, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,6 +1008,10 @@ func (r *messageReader) Read(b []byte) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
func (r *messageReader) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadMessage is a helper method for getting a reader using NextReader and
|
||||
// reading from that reader to a buffer.
|
||||
func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
|
||||
@@ -898,6 +1039,38 @@ func (c *Conn) SetReadLimit(limit int64) {
|
||||
c.readLimit = limit
|
||||
}
|
||||
|
||||
// CloseHandler returns the current close handler
|
||||
func (c *Conn) CloseHandler() func(code int, text string) error {
|
||||
return c.handleClose
|
||||
}
|
||||
|
||||
// SetCloseHandler sets the handler for close messages received from the peer.
|
||||
// The code argument to h is the received close code or CloseNoStatusReceived
|
||||
// if the close message is empty. The default close handler sends a close frame
|
||||
// back to the peer.
|
||||
//
|
||||
// The application must read the connection to process close messages as
|
||||
// described in the section on Control Frames above.
|
||||
//
|
||||
// The connection read methods return a CloseError when a close frame is
|
||||
// received. Most applications should handle close messages as part of their
|
||||
// normal error handling. Applications should only set a close handler when the
|
||||
// application must perform some action before sending a close frame back to
|
||||
// the peer.
|
||||
func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
|
||||
if h == nil {
|
||||
h = func(code int, text string) error {
|
||||
message := []byte{}
|
||||
if code != CloseNoStatusReceived {
|
||||
message = FormatCloseMessage(code, "")
|
||||
}
|
||||
c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
c.handleClose = h
|
||||
}
|
||||
|
||||
// PingHandler returns the current ping handler
|
||||
func (c *Conn) PingHandler() func(appData string) error {
|
||||
return c.handlePing
|
||||
@@ -906,6 +1079,9 @@ func (c *Conn) PingHandler() func(appData string) error {
|
||||
// SetPingHandler sets the handler for ping messages received from the peer.
|
||||
// The appData argument to h is the PING frame application data. The default
|
||||
// ping handler sends a pong to the peer.
|
||||
//
|
||||
// The application must read the connection to process ping messages as
|
||||
// described in the section on Control Frames above.
|
||||
func (c *Conn) SetPingHandler(h func(appData string) error) {
|
||||
if h == nil {
|
||||
h = func(message string) error {
|
||||
@@ -929,6 +1105,9 @@ func (c *Conn) PongHandler() func(appData string) error {
|
||||
// SetPongHandler sets the handler for pong messages received from the peer.
|
||||
// The appData argument to h is the PONG frame application data. The default
|
||||
// pong handler does nothing.
|
||||
//
|
||||
// The application must read the connection to process ping messages as
|
||||
// described in the section on Control Frames above.
|
||||
func (c *Conn) SetPongHandler(h func(appData string) error) {
|
||||
if h == nil {
|
||||
h = func(string) error { return nil }
|
||||
@@ -942,6 +1121,25 @@ func (c *Conn) UnderlyingConn() net.Conn {
|
||||
return c.conn
|
||||
}
|
||||
|
||||
// EnableWriteCompression enables and disables write compression of
|
||||
// subsequent text and binary messages. This function is a noop if
|
||||
// compression was not negotiated with the peer.
|
||||
func (c *Conn) EnableWriteCompression(enable bool) {
|
||||
c.enableWriteCompression = enable
|
||||
}
|
||||
|
||||
// SetCompressionLevel sets the flate compression level for subsequent text and
|
||||
// binary messages. This function is a noop if compression was not negotiated
|
||||
// with the peer. See the compress/flate package for a description of
|
||||
// compression levels.
|
||||
func (c *Conn) SetCompressionLevel(level int) error {
|
||||
if !isValidCompressionLevel(level) {
|
||||
return errors.New("websocket: invalid compression level")
|
||||
}
|
||||
c.compressionLevel = level
|
||||
return nil
|
||||
}
|
||||
|
||||
// FormatCloseMessage formats closeCode and text as a WebSocket close message.
|
||||
func FormatCloseMessage(closeCode int, text string) []byte {
|
||||
buf := make([]byte, 2+len(text))
|
||||
|
||||
+37
-10
@@ -6,9 +6,8 @@
|
||||
//
|
||||
// Overview
|
||||
//
|
||||
// The Conn type represents a WebSocket connection. A server application uses
|
||||
// the Upgrade function from an Upgrader object with a HTTP request handler
|
||||
// to get a pointer to a Conn:
|
||||
// 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,
|
||||
@@ -33,7 +32,7 @@
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// if err = conn.WriteMessage(messageType, p); err != nil {
|
||||
// if err := conn.WriteMessage(messageType, p); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
@@ -118,9 +117,10 @@
|
||||
//
|
||||
// Applications are responsible for ensuring that no more than one goroutine
|
||||
// calls the write methods (NextWriter, SetWriteDeadline, WriteMessage,
|
||||
// WriteJSON) concurrently and that no more than one goroutine calls the read
|
||||
// methods (NextReader, SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler,
|
||||
// SetPingHandler) concurrently.
|
||||
// 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.
|
||||
@@ -146,7 +146,34 @@
|
||||
// CheckOrigin: func(r *http.Request) bool { return true },
|
||||
// }
|
||||
//
|
||||
// The deprecated Upgrade function does not enforce an origin policy. It's the
|
||||
// application's responsibility to check the Origin header before calling
|
||||
// Upgrade.
|
||||
// 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
|
||||
|
||||
+8
-3
@@ -9,12 +9,14 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// WriteJSON is deprecated, use c.WriteJSON instead.
|
||||
// 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 to the connection.
|
||||
// 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.
|
||||
@@ -31,7 +33,10 @@ func (c *Conn) WriteJSON(v interface{}) error {
|
||||
return err2
|
||||
}
|
||||
|
||||
// ReadJSON is deprecated, use c.ReadJSON instead.
|
||||
// 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)
|
||||
}
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// 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
@@ -0,0 +1,15 @@
|
||||
// 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
@@ -0,0 +1,103 @@
|
||||
// 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 }
|
||||
+50
-18
@@ -28,8 +28,9 @@ type Upgrader struct {
|
||||
HandshakeTimeout time.Duration
|
||||
|
||||
// ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
|
||||
// size is zero, then a default value of 4096 is used. The I/O buffer sizes
|
||||
// do not limit the size of the messages that can be sent or received.
|
||||
// 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
|
||||
@@ -46,6 +47,12 @@ type Upgrader struct {
|
||||
// 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) {
|
||||
@@ -53,6 +60,7 @@ func (u *Upgrader) returnError(w http.ResponseWriter, r *http.Request, status in
|
||||
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
|
||||
@@ -97,18 +105,23 @@ func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header
|
||||
// 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: method not GET")
|
||||
return u.returnError(w, r, http.StatusMethodNotAllowed, "websocket: not a websocket handshake: request method is not GET")
|
||||
}
|
||||
if values := r.Header["Sec-Websocket-Version"]; len(values) == 0 || values[0] != "13" {
|
||||
return u.returnError(w, r, http.StatusBadRequest, "websocket: version != 13")
|
||||
|
||||
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: could not find connection header with token '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: could not find upgrade header with token '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
|
||||
@@ -116,19 +129,30 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
||||
checkOrigin = checkSameOrigin
|
||||
}
|
||||
if !checkOrigin(r) {
|
||||
return u.returnError(w, r, http.StatusForbidden, "websocket: origin not allowed")
|
||||
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: key missing or blank")
|
||||
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
|
||||
br *bufio.Reader
|
||||
err error
|
||||
)
|
||||
|
||||
@@ -136,21 +160,25 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
||||
if !ok {
|
||||
return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
|
||||
}
|
||||
var rw *bufio.ReadWriter
|
||||
netConn, rw, err = h.Hijack()
|
||||
var brw *bufio.ReadWriter
|
||||
netConn, brw, err = h.Hijack()
|
||||
if err != nil {
|
||||
return u.returnError(w, r, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
br = rw.Reader
|
||||
|
||||
if br.Buffered() > 0 {
|
||||
if brw.Reader.Buffered() > 0 {
|
||||
netConn.Close()
|
||||
return nil, errors.New("websocket: client sent data before handshake is complete")
|
||||
}
|
||||
|
||||
c := newConn(netConn, true, u.ReadBufferSize, u.WriteBufferSize)
|
||||
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)...)
|
||||
@@ -160,6 +188,9 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
||||
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
|
||||
@@ -199,10 +230,11 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
|
||||
|
||||
// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
|
||||
//
|
||||
// This function is deprecated, use websocket.Upgrader instead.
|
||||
// Deprecated: Use websocket.Upgrader instead.
|
||||
//
|
||||
// The application is responsible for checking the request origin before
|
||||
// calling Upgrade. An example implementation of the same origin policy is:
|
||||
// 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)
|
||||
|
||||
+2
-2
@@ -111,14 +111,14 @@ func nextTokenOrQuoted(s string) (value string, rest string) {
|
||||
case escape:
|
||||
escape = false
|
||||
p[j] = b
|
||||
j += 1
|
||||
j++
|
||||
case b == '\\':
|
||||
escape = true
|
||||
case b == '"':
|
||||
return string(p[:j]), s[i+1:]
|
||||
default:
|
||||
p[j] = b
|
||||
j += 1
|
||||
j++
|
||||
}
|
||||
}
|
||||
return "", ""
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
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
@@ -0,0 +1,52 @@
|
||||
# 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
@@ -0,0 +1,32 @@
|
||||
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
@@ -0,0 +1,269 @@
|
||||
// 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
@@ -0,0 +1,186 @@
|
||||
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
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
FROM rancher/dind:v0.3.0
|
||||
COPY ./scripts/bootstrap /scripts/bootstrap
|
||||
RUN /scripts/bootstrap
|
||||
WORKDIR /source
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
# Go Bindings for Rancher API
|
||||
|
||||
# Building
|
||||
|
||||
```sh
|
||||
godep go build ./client
|
||||
```
|
||||
|
||||
# Tests
|
||||
|
||||
```sh
|
||||
godep go test ./client
|
||||
```
|
||||
# Contact
|
||||
For bugs, questions, comments, corrections, suggestions, etc., open an issue in
|
||||
[rancher/rancher](//github.com/rancher/rancher/issues) with a title starting with `[go-rancher] `.
|
||||
|
||||
Or just [click here](//github.com/rancher/rancher/issues/new?title=%5Bgo-rancher%5D%20) to create a new issue.
|
||||
|
||||
|
||||
# License
|
||||
Copyright (c) 2014-2015 [Rancher Labs, Inc.](http://rancher.com)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package client
|
||||
|
||||
type RancherBaseClient struct {
|
||||
Opts *ClientOpts
|
||||
Schemas *Schemas
|
||||
Types map[string]Schema
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_LABEL_INPUT_TYPE = "addLabelInput"
|
||||
)
|
||||
|
||||
type AddLabelInput struct {
|
||||
Resource
|
||||
|
||||
Key string `json:"key,omitempty"`
|
||||
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
type AddLabelInputCollection struct {
|
||||
Collection
|
||||
Data []AddLabelInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AddLabelInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddLabelInputOperations interface {
|
||||
List(opts *ListOpts) (*AddLabelInputCollection, error)
|
||||
Create(opts *AddLabelInput) (*AddLabelInput, error)
|
||||
Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error)
|
||||
ById(id string) (*AddLabelInput, error)
|
||||
Delete(container *AddLabelInput) error
|
||||
}
|
||||
|
||||
func newAddLabelInputClient(rancherClient *RancherClient) *AddLabelInputClient {
|
||||
return &AddLabelInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddLabelInputClient) Create(container *AddLabelInput) (*AddLabelInput, error) {
|
||||
resp := &AddLabelInput{}
|
||||
err := c.rancherClient.doCreate(ADD_LABEL_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLabelInputClient) Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error) {
|
||||
resp := &AddLabelInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_LABEL_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLabelInputClient) List(opts *ListOpts) (*AddLabelInputCollection, error) {
|
||||
resp := &AddLabelInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_LABEL_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLabelInputClient) ById(id string) (*AddLabelInput, error) {
|
||||
resp := &AddLabelInput{}
|
||||
err := c.rancherClient.doById(ADD_LABEL_INPUT_TYPE, id, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLabelInputClient) Delete(container *AddLabelInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_LABEL_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_LOAD_BALANCER_INPUT_TYPE = "addLoadBalancerInput"
|
||||
)
|
||||
|
||||
type AddLoadBalancerInput struct {
|
||||
Resource
|
||||
|
||||
LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"`
|
||||
|
||||
Weight int64 `json:"weight,omitempty" yaml:"weight,omitempty"`
|
||||
}
|
||||
|
||||
type AddLoadBalancerInputCollection struct {
|
||||
Collection
|
||||
Data []AddLoadBalancerInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AddLoadBalancerInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddLoadBalancerInputOperations interface {
|
||||
List(opts *ListOpts) (*AddLoadBalancerInputCollection, error)
|
||||
Create(opts *AddLoadBalancerInput) (*AddLoadBalancerInput, error)
|
||||
Update(existing *AddLoadBalancerInput, updates interface{}) (*AddLoadBalancerInput, error)
|
||||
ById(id string) (*AddLoadBalancerInput, error)
|
||||
Delete(container *AddLoadBalancerInput) error
|
||||
}
|
||||
|
||||
func newAddLoadBalancerInputClient(rancherClient *RancherClient) *AddLoadBalancerInputClient {
|
||||
return &AddLoadBalancerInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddLoadBalancerInputClient) Create(container *AddLoadBalancerInput) (*AddLoadBalancerInput, error) {
|
||||
resp := &AddLoadBalancerInput{}
|
||||
err := c.rancherClient.doCreate(ADD_LOAD_BALANCER_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLoadBalancerInputClient) Update(existing *AddLoadBalancerInput, updates interface{}) (*AddLoadBalancerInput, error) {
|
||||
resp := &AddLoadBalancerInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_LOAD_BALANCER_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLoadBalancerInputClient) List(opts *ListOpts) (*AddLoadBalancerInputCollection, error) {
|
||||
resp := &AddLoadBalancerInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_LOAD_BALANCER_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLoadBalancerInputClient) ById(id string) (*AddLoadBalancerInput, error) {
|
||||
resp := &AddLoadBalancerInput{}
|
||||
err := c.rancherClient.doById(ADD_LOAD_BALANCER_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddLoadBalancerInputClient) Delete(container *AddLoadBalancerInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_LOAD_BALANCER_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE = "addRemoveClusterHostInput"
|
||||
)
|
||||
|
||||
type AddRemoveClusterHostInput struct {
|
||||
Resource
|
||||
|
||||
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveClusterHostInputCollection struct {
|
||||
Collection
|
||||
Data []AddRemoveClusterHostInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveClusterHostInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddRemoveClusterHostInputOperations interface {
|
||||
List(opts *ListOpts) (*AddRemoveClusterHostInputCollection, error)
|
||||
Create(opts *AddRemoveClusterHostInput) (*AddRemoveClusterHostInput, error)
|
||||
Update(existing *AddRemoveClusterHostInput, updates interface{}) (*AddRemoveClusterHostInput, error)
|
||||
ById(id string) (*AddRemoveClusterHostInput, error)
|
||||
Delete(container *AddRemoveClusterHostInput) error
|
||||
}
|
||||
|
||||
func newAddRemoveClusterHostInputClient(rancherClient *RancherClient) *AddRemoveClusterHostInputClient {
|
||||
return &AddRemoveClusterHostInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddRemoveClusterHostInputClient) Create(container *AddRemoveClusterHostInput) (*AddRemoveClusterHostInput, error) {
|
||||
resp := &AddRemoveClusterHostInput{}
|
||||
err := c.rancherClient.doCreate(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveClusterHostInputClient) Update(existing *AddRemoveClusterHostInput, updates interface{}) (*AddRemoveClusterHostInput, error) {
|
||||
resp := &AddRemoveClusterHostInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveClusterHostInputClient) List(opts *ListOpts) (*AddRemoveClusterHostInputCollection, error) {
|
||||
resp := &AddRemoveClusterHostInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveClusterHostInputClient) ById(id string) (*AddRemoveClusterHostInput, error) {
|
||||
resp := &AddRemoveClusterHostInput{}
|
||||
err := c.rancherClient.doById(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveClusterHostInputClient) Delete(container *AddRemoveClusterHostInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_REMOVE_CLUSTER_HOST_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE = "addRemoveLoadBalancerHostInput"
|
||||
)
|
||||
|
||||
type AddRemoveLoadBalancerHostInput struct {
|
||||
Resource
|
||||
|
||||
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerHostInputCollection struct {
|
||||
Collection
|
||||
Data []AddRemoveLoadBalancerHostInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerHostInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerHostInputOperations interface {
|
||||
List(opts *ListOpts) (*AddRemoveLoadBalancerHostInputCollection, error)
|
||||
Create(opts *AddRemoveLoadBalancerHostInput) (*AddRemoveLoadBalancerHostInput, error)
|
||||
Update(existing *AddRemoveLoadBalancerHostInput, updates interface{}) (*AddRemoveLoadBalancerHostInput, error)
|
||||
ById(id string) (*AddRemoveLoadBalancerHostInput, error)
|
||||
Delete(container *AddRemoveLoadBalancerHostInput) error
|
||||
}
|
||||
|
||||
func newAddRemoveLoadBalancerHostInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerHostInputClient {
|
||||
return &AddRemoveLoadBalancerHostInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerHostInputClient) Create(container *AddRemoveLoadBalancerHostInput) (*AddRemoveLoadBalancerHostInput, error) {
|
||||
resp := &AddRemoveLoadBalancerHostInput{}
|
||||
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerHostInputClient) Update(existing *AddRemoveLoadBalancerHostInput, updates interface{}) (*AddRemoveLoadBalancerHostInput, error) {
|
||||
resp := &AddRemoveLoadBalancerHostInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerHostInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerHostInputCollection, error) {
|
||||
resp := &AddRemoveLoadBalancerHostInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerHostInputClient) ById(id string) (*AddRemoveLoadBalancerHostInput, error) {
|
||||
resp := &AddRemoveLoadBalancerHostInput{}
|
||||
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerHostInputClient) Delete(container *AddRemoveLoadBalancerHostInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_HOST_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE = "addRemoveLoadBalancerListenerInput"
|
||||
)
|
||||
|
||||
type AddRemoveLoadBalancerListenerInput struct {
|
||||
Resource
|
||||
|
||||
LoadBalancerListenerId string `json:"loadBalancerListenerId,omitempty" yaml:"load_balancer_listener_id,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerListenerInputCollection struct {
|
||||
Collection
|
||||
Data []AddRemoveLoadBalancerListenerInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerListenerInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerListenerInputOperations interface {
|
||||
List(opts *ListOpts) (*AddRemoveLoadBalancerListenerInputCollection, error)
|
||||
Create(opts *AddRemoveLoadBalancerListenerInput) (*AddRemoveLoadBalancerListenerInput, error)
|
||||
Update(existing *AddRemoveLoadBalancerListenerInput, updates interface{}) (*AddRemoveLoadBalancerListenerInput, error)
|
||||
ById(id string) (*AddRemoveLoadBalancerListenerInput, error)
|
||||
Delete(container *AddRemoveLoadBalancerListenerInput) error
|
||||
}
|
||||
|
||||
func newAddRemoveLoadBalancerListenerInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerListenerInputClient {
|
||||
return &AddRemoveLoadBalancerListenerInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerListenerInputClient) Create(container *AddRemoveLoadBalancerListenerInput) (*AddRemoveLoadBalancerListenerInput, error) {
|
||||
resp := &AddRemoveLoadBalancerListenerInput{}
|
||||
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerListenerInputClient) Update(existing *AddRemoveLoadBalancerListenerInput, updates interface{}) (*AddRemoveLoadBalancerListenerInput, error) {
|
||||
resp := &AddRemoveLoadBalancerListenerInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerListenerInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerListenerInputCollection, error) {
|
||||
resp := &AddRemoveLoadBalancerListenerInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerListenerInputClient) ById(id string) (*AddRemoveLoadBalancerListenerInput, error) {
|
||||
resp := &AddRemoveLoadBalancerListenerInput{}
|
||||
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerListenerInputClient) Delete(container *AddRemoveLoadBalancerListenerInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_LISTENER_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
vendor/github.com/rancher/go-rancher/client/generated_add_remove_load_balancer_service_link_input.go
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE = "addRemoveLoadBalancerServiceLinkInput"
|
||||
)
|
||||
|
||||
type AddRemoveLoadBalancerServiceLinkInput struct {
|
||||
Resource
|
||||
|
||||
ServiceLink LoadBalancerServiceLink `json:"serviceLink,omitempty" yaml:"service_link,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerServiceLinkInputCollection struct {
|
||||
Collection
|
||||
Data []AddRemoveLoadBalancerServiceLinkInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerServiceLinkInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerServiceLinkInputOperations interface {
|
||||
List(opts *ListOpts) (*AddRemoveLoadBalancerServiceLinkInputCollection, error)
|
||||
Create(opts *AddRemoveLoadBalancerServiceLinkInput) (*AddRemoveLoadBalancerServiceLinkInput, error)
|
||||
Update(existing *AddRemoveLoadBalancerServiceLinkInput, updates interface{}) (*AddRemoveLoadBalancerServiceLinkInput, error)
|
||||
ById(id string) (*AddRemoveLoadBalancerServiceLinkInput, error)
|
||||
Delete(container *AddRemoveLoadBalancerServiceLinkInput) error
|
||||
}
|
||||
|
||||
func newAddRemoveLoadBalancerServiceLinkInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerServiceLinkInputClient {
|
||||
return &AddRemoveLoadBalancerServiceLinkInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerServiceLinkInputClient) Create(container *AddRemoveLoadBalancerServiceLinkInput) (*AddRemoveLoadBalancerServiceLinkInput, error) {
|
||||
resp := &AddRemoveLoadBalancerServiceLinkInput{}
|
||||
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerServiceLinkInputClient) Update(existing *AddRemoveLoadBalancerServiceLinkInput, updates interface{}) (*AddRemoveLoadBalancerServiceLinkInput, error) {
|
||||
resp := &AddRemoveLoadBalancerServiceLinkInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerServiceLinkInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerServiceLinkInputCollection, error) {
|
||||
resp := &AddRemoveLoadBalancerServiceLinkInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerServiceLinkInputClient) ById(id string) (*AddRemoveLoadBalancerServiceLinkInput, error) {
|
||||
resp := &AddRemoveLoadBalancerServiceLinkInput{}
|
||||
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerServiceLinkInputClient) Delete(container *AddRemoveLoadBalancerServiceLinkInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_SERVICE_LINK_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE = "addRemoveLoadBalancerTargetInput"
|
||||
)
|
||||
|
||||
type AddRemoveLoadBalancerTargetInput struct {
|
||||
Resource
|
||||
|
||||
LoadBalancerTarget LoadBalancerTarget `json:"loadBalancerTarget,omitempty" yaml:"load_balancer_target,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerTargetInputCollection struct {
|
||||
Collection
|
||||
Data []AddRemoveLoadBalancerTargetInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerTargetInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type AddRemoveLoadBalancerTargetInputOperations interface {
|
||||
List(opts *ListOpts) (*AddRemoveLoadBalancerTargetInputCollection, error)
|
||||
Create(opts *AddRemoveLoadBalancerTargetInput) (*AddRemoveLoadBalancerTargetInput, error)
|
||||
Update(existing *AddRemoveLoadBalancerTargetInput, updates interface{}) (*AddRemoveLoadBalancerTargetInput, error)
|
||||
ById(id string) (*AddRemoveLoadBalancerTargetInput, error)
|
||||
Delete(container *AddRemoveLoadBalancerTargetInput) error
|
||||
}
|
||||
|
||||
func newAddRemoveLoadBalancerTargetInputClient(rancherClient *RancherClient) *AddRemoveLoadBalancerTargetInputClient {
|
||||
return &AddRemoveLoadBalancerTargetInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerTargetInputClient) Create(container *AddRemoveLoadBalancerTargetInput) (*AddRemoveLoadBalancerTargetInput, error) {
|
||||
resp := &AddRemoveLoadBalancerTargetInput{}
|
||||
err := c.rancherClient.doCreate(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerTargetInputClient) Update(existing *AddRemoveLoadBalancerTargetInput, updates interface{}) (*AddRemoveLoadBalancerTargetInput, error) {
|
||||
resp := &AddRemoveLoadBalancerTargetInput{}
|
||||
err := c.rancherClient.doUpdate(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerTargetInputClient) List(opts *ListOpts) (*AddRemoveLoadBalancerTargetInputCollection, error) {
|
||||
resp := &AddRemoveLoadBalancerTargetInputCollection{}
|
||||
err := c.rancherClient.doList(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerTargetInputClient) ById(id string) (*AddRemoveLoadBalancerTargetInput, error) {
|
||||
resp := &AddRemoveLoadBalancerTargetInput{}
|
||||
err := c.rancherClient.doById(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *AddRemoveLoadBalancerTargetInputClient) Delete(container *AddRemoveLoadBalancerTargetInput) error {
|
||||
return c.rancherClient.doResourceDelete(ADD_REMOVE_LOAD_BALANCER_TARGET_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-223
@@ -1,223 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
CLUSTER_TYPE = "cluster"
|
||||
)
|
||||
|
||||
type Cluster struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
|
||||
|
||||
AgentState string `json:"agentState,omitempty" yaml:"agent_state,omitempty"`
|
||||
|
||||
ApiProxy string `json:"apiProxy,omitempty" yaml:"api_proxy,omitempty"`
|
||||
|
||||
ComputeTotal int64 `json:"computeTotal,omitempty" yaml:"compute_total,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"`
|
||||
|
||||
DiscoverySpec string `json:"discoverySpec,omitempty" yaml:"discovery_spec,omitempty"`
|
||||
|
||||
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
|
||||
|
||||
Info interface{} `json:"info,omitempty" yaml:"info,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
Labels map[string]interface{} `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
PhysicalHostId string `json:"physicalHostId,omitempty" yaml:"physical_host_id,omitempty"`
|
||||
|
||||
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
|
||||
PublicEndpoints []interface{} `json:"publicEndpoints,omitempty" yaml:"public_endpoints,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 ClusterCollection struct {
|
||||
Collection
|
||||
Data []Cluster `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ClusterOperations interface {
|
||||
List(opts *ListOpts) (*ClusterCollection, error)
|
||||
Create(opts *Cluster) (*Cluster, error)
|
||||
Update(existing *Cluster, updates interface{}) (*Cluster, error)
|
||||
ById(id string) (*Cluster, error)
|
||||
Delete(container *Cluster) error
|
||||
|
||||
ActionActivate(*Cluster) (*Host, error)
|
||||
|
||||
ActionAddhost(*Cluster, *AddRemoveClusterHostInput) (*Cluster, error)
|
||||
|
||||
ActionCreate(*Cluster) (*Host, error)
|
||||
|
||||
ActionDeactivate(*Cluster) (*Host, error)
|
||||
|
||||
ActionDockersocket(*Cluster) (*HostAccess, error)
|
||||
|
||||
ActionPurge(*Cluster) (*Host, error)
|
||||
|
||||
ActionRemove(*Cluster) (*Host, error)
|
||||
|
||||
ActionRemovehost(*Cluster, *AddRemoveClusterHostInput) (*Cluster, error)
|
||||
|
||||
ActionRestore(*Cluster) (*Host, error)
|
||||
|
||||
ActionUpdate(*Cluster) (*Host, error)
|
||||
}
|
||||
|
||||
func newClusterClient(rancherClient *RancherClient) *ClusterClient {
|
||||
return &ClusterClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ClusterClient) Create(container *Cluster) (*Cluster, error) {
|
||||
resp := &Cluster{}
|
||||
err := c.rancherClient.doCreate(CLUSTER_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) Update(existing *Cluster, updates interface{}) (*Cluster, error) {
|
||||
resp := &Cluster{}
|
||||
err := c.rancherClient.doUpdate(CLUSTER_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) List(opts *ListOpts) (*ClusterCollection, error) {
|
||||
resp := &ClusterCollection{}
|
||||
err := c.rancherClient.doList(CLUSTER_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ById(id string) (*Cluster, error) {
|
||||
resp := &Cluster{}
|
||||
err := c.rancherClient.doById(CLUSTER_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) Delete(container *Cluster) error {
|
||||
return c.rancherClient.doResourceDelete(CLUSTER_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionActivate(resource *Cluster) (*Host, error) {
|
||||
|
||||
resp := &Host{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionAddhost(resource *Cluster, input *AddRemoveClusterHostInput) (*Cluster, error) {
|
||||
|
||||
resp := &Cluster{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "addhost", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionCreate(resource *Cluster) (*Host, error) {
|
||||
|
||||
resp := &Host{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionDeactivate(resource *Cluster) (*Host, error) {
|
||||
|
||||
resp := &Host{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionDockersocket(resource *Cluster) (*HostAccess, error) {
|
||||
|
||||
resp := &HostAccess{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "dockersocket", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionPurge(resource *Cluster) (*Host, error) {
|
||||
|
||||
resp := &Host{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "purge", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionRemove(resource *Cluster) (*Host, error) {
|
||||
|
||||
resp := &Host{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionRemovehost(resource *Cluster, input *AddRemoveClusterHostInput) (*Cluster, error) {
|
||||
|
||||
resp := &Cluster{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "removehost", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionRestore(resource *Cluster) (*Host, error) {
|
||||
|
||||
resp := &Host{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "restore", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ClusterClient) ActionUpdate(resource *Cluster) (*Host, error) {
|
||||
|
||||
resp := &Host{}
|
||||
|
||||
err := c.rancherClient.doAction(CLUSTER_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
DYNAMIC_SCHEMA_TYPE = "dynamicSchema"
|
||||
)
|
||||
|
||||
type DynamicSchema 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"`
|
||||
|
||||
Definition string `json:"definition,omitempty" yaml:"definition,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"`
|
||||
|
||||
Parent string `json:"parent,omitempty" yaml:"parent,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
Roles []string `json:"roles,omitempty" yaml:"roles,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 DynamicSchemaCollection struct {
|
||||
Collection
|
||||
Data []DynamicSchema `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type DynamicSchemaClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type DynamicSchemaOperations interface {
|
||||
List(opts *ListOpts) (*DynamicSchemaCollection, error)
|
||||
Create(opts *DynamicSchema) (*DynamicSchema, error)
|
||||
Update(existing *DynamicSchema, updates interface{}) (*DynamicSchema, error)
|
||||
ById(id string) (*DynamicSchema, error)
|
||||
Delete(container *DynamicSchema) error
|
||||
|
||||
ActionCreate(*DynamicSchema) (*DynamicSchema, error)
|
||||
|
||||
ActionRemove(*DynamicSchema) (*DynamicSchema, error)
|
||||
}
|
||||
|
||||
func newDynamicSchemaClient(rancherClient *RancherClient) *DynamicSchemaClient {
|
||||
return &DynamicSchemaClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *DynamicSchemaClient) Create(container *DynamicSchema) (*DynamicSchema, error) {
|
||||
resp := &DynamicSchema{}
|
||||
err := c.rancherClient.doCreate(DYNAMIC_SCHEMA_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DynamicSchemaClient) Update(existing *DynamicSchema, updates interface{}) (*DynamicSchema, error) {
|
||||
resp := &DynamicSchema{}
|
||||
err := c.rancherClient.doUpdate(DYNAMIC_SCHEMA_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DynamicSchemaClient) List(opts *ListOpts) (*DynamicSchemaCollection, error) {
|
||||
resp := &DynamicSchemaCollection{}
|
||||
err := c.rancherClient.doList(DYNAMIC_SCHEMA_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DynamicSchemaClient) ById(id string) (*DynamicSchema, error) {
|
||||
resp := &DynamicSchema{}
|
||||
err := c.rancherClient.doById(DYNAMIC_SCHEMA_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DynamicSchemaClient) Delete(container *DynamicSchema) error {
|
||||
return c.rancherClient.doResourceDelete(DYNAMIC_SCHEMA_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *DynamicSchemaClient) ActionCreate(resource *DynamicSchema) (*DynamicSchema, error) {
|
||||
|
||||
resp := &DynamicSchema{}
|
||||
|
||||
err := c.rancherClient.doAction(DYNAMIC_SCHEMA_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *DynamicSchemaClient) ActionRemove(resource *DynamicSchema) (*DynamicSchema, error) {
|
||||
|
||||
resp := &DynamicSchema{}
|
||||
|
||||
err := c.rancherClient.doAction(DYNAMIC_SCHEMA_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-252
@@ -1,252 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ENVIRONMENT_TYPE = "environment"
|
||||
)
|
||||
|
||||
type Environment 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"`
|
||||
|
||||
DockerCompose string `json:"dockerCompose,omitempty" yaml:"docker_compose,omitempty"`
|
||||
|
||||
Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,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"`
|
||||
|
||||
Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"`
|
||||
|
||||
PreviousEnvironment map[string]interface{} `json:"previousEnvironment,omitempty" yaml:"previous_environment,omitempty"`
|
||||
|
||||
PreviousExternalId string `json:"previousExternalId,omitempty" yaml:"previous_external_id,omitempty"`
|
||||
|
||||
RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
StartOnCreate bool `json:"startOnCreate,omitempty" yaml:"start_on_create,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 EnvironmentCollection struct {
|
||||
Collection
|
||||
Data []Environment `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type EnvironmentClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type EnvironmentOperations interface {
|
||||
List(opts *ListOpts) (*EnvironmentCollection, error)
|
||||
Create(opts *Environment) (*Environment, error)
|
||||
Update(existing *Environment, updates interface{}) (*Environment, error)
|
||||
ById(id string) (*Environment, error)
|
||||
Delete(container *Environment) error
|
||||
|
||||
ActionActivateservices(*Environment) (*Environment, error)
|
||||
|
||||
ActionAddoutputs(*Environment, *AddOutputsInput) (*Environment, error)
|
||||
|
||||
ActionCancelrollback(*Environment) (*Environment, error)
|
||||
|
||||
ActionCancelupgrade(*Environment) (*Environment, error)
|
||||
|
||||
ActionCreate(*Environment) (*Environment, error)
|
||||
|
||||
ActionDeactivateservices(*Environment) (*Environment, error)
|
||||
|
||||
ActionError(*Environment) (*Environment, error)
|
||||
|
||||
ActionExportconfig(*Environment, *ComposeConfigInput) (*ComposeConfig, error)
|
||||
|
||||
ActionFinishupgrade(*Environment) (*Environment, error)
|
||||
|
||||
ActionRemove(*Environment) (*Environment, error)
|
||||
|
||||
ActionRollback(*Environment) (*Environment, error)
|
||||
|
||||
ActionUpdate(*Environment) (*Environment, error)
|
||||
|
||||
ActionUpgrade(*Environment, *EnvironmentUpgrade) (*Environment, error)
|
||||
}
|
||||
|
||||
func newEnvironmentClient(rancherClient *RancherClient) *EnvironmentClient {
|
||||
return &EnvironmentClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) Create(container *Environment) (*Environment, error) {
|
||||
resp := &Environment{}
|
||||
err := c.rancherClient.doCreate(ENVIRONMENT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) Update(existing *Environment, updates interface{}) (*Environment, error) {
|
||||
resp := &Environment{}
|
||||
err := c.rancherClient.doUpdate(ENVIRONMENT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) List(opts *ListOpts) (*EnvironmentCollection, error) {
|
||||
resp := &EnvironmentCollection{}
|
||||
err := c.rancherClient.doList(ENVIRONMENT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ById(id string) (*Environment, error) {
|
||||
resp := &Environment{}
|
||||
err := c.rancherClient.doById(ENVIRONMENT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) Delete(container *Environment) error {
|
||||
return c.rancherClient.doResourceDelete(ENVIRONMENT_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionActivateservices(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "activateservices", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionAddoutputs(resource *Environment, input *AddOutputsInput) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "addoutputs", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionCancelrollback(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "cancelrollback", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionCancelupgrade(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "cancelupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionCreate(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionDeactivateservices(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "deactivateservices", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionError(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "error", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionExportconfig(resource *Environment, input *ComposeConfigInput) (*ComposeConfig, error) {
|
||||
|
||||
resp := &ComposeConfig{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "exportconfig", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionFinishupgrade(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "finishupgrade", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionRemove(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionRollback(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "rollback", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionUpdate(resource *Environment) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentClient) ActionUpgrade(resource *Environment, input *EnvironmentUpgrade) (*Environment, error) {
|
||||
|
||||
resp := &Environment{}
|
||||
|
||||
err := c.rancherClient.doAction(ENVIRONMENT_TYPE, "upgrade", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
-73
@@ -1,73 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
ENVIRONMENT_UPGRADE_TYPE = "environmentUpgrade"
|
||||
)
|
||||
|
||||
type EnvironmentUpgrade struct {
|
||||
Resource
|
||||
|
||||
DockerCompose string `json:"dockerCompose,omitempty" yaml:"docker_compose,omitempty"`
|
||||
|
||||
Environment map[string]interface{} `json:"environment,omitempty" yaml:"environment,omitempty"`
|
||||
|
||||
ExternalId string `json:"externalId,omitempty" yaml:"external_id,omitempty"`
|
||||
|
||||
RancherCompose string `json:"rancherCompose,omitempty" yaml:"rancher_compose,omitempty"`
|
||||
}
|
||||
|
||||
type EnvironmentUpgradeCollection struct {
|
||||
Collection
|
||||
Data []EnvironmentUpgrade `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type EnvironmentUpgradeClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type EnvironmentUpgradeOperations interface {
|
||||
List(opts *ListOpts) (*EnvironmentUpgradeCollection, error)
|
||||
Create(opts *EnvironmentUpgrade) (*EnvironmentUpgrade, error)
|
||||
Update(existing *EnvironmentUpgrade, updates interface{}) (*EnvironmentUpgrade, error)
|
||||
ById(id string) (*EnvironmentUpgrade, error)
|
||||
Delete(container *EnvironmentUpgrade) error
|
||||
}
|
||||
|
||||
func newEnvironmentUpgradeClient(rancherClient *RancherClient) *EnvironmentUpgradeClient {
|
||||
return &EnvironmentUpgradeClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *EnvironmentUpgradeClient) Create(container *EnvironmentUpgrade) (*EnvironmentUpgrade, error) {
|
||||
resp := &EnvironmentUpgrade{}
|
||||
err := c.rancherClient.doCreate(ENVIRONMENT_UPGRADE_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentUpgradeClient) Update(existing *EnvironmentUpgrade, updates interface{}) (*EnvironmentUpgrade, error) {
|
||||
resp := &EnvironmentUpgrade{}
|
||||
err := c.rancherClient.doUpdate(ENVIRONMENT_UPGRADE_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentUpgradeClient) List(opts *ListOpts) (*EnvironmentUpgradeCollection, error) {
|
||||
resp := &EnvironmentUpgradeCollection{}
|
||||
err := c.rancherClient.doList(ENVIRONMENT_UPGRADE_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentUpgradeClient) ById(id string) (*EnvironmentUpgrade, error) {
|
||||
resp := &EnvironmentUpgrade{}
|
||||
err := c.rancherClient.doById(ENVIRONMENT_UPGRADE_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *EnvironmentUpgradeClient) Delete(container *EnvironmentUpgrade) error {
|
||||
return c.rancherClient.doResourceDelete(ENVIRONMENT_UPGRADE_TYPE, &container.Resource)
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
EXOSCALE_CONFIG_TYPE = "exoscaleConfig"
|
||||
)
|
||||
|
||||
type ExoscaleConfig struct {
|
||||
Resource
|
||||
|
||||
ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"`
|
||||
|
||||
ApiSecretKey string `json:"apiSecretKey,omitempty" yaml:"api_secret_key,omitempty"`
|
||||
|
||||
AvailabilityZone string `json:"availabilityZone,omitempty" yaml:"availability_zone,omitempty"`
|
||||
|
||||
DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"`
|
||||
|
||||
Image string `json:"image,omitempty" yaml:"image,omitempty"`
|
||||
|
||||
InstanceProfile string `json:"instanceProfile,omitempty" yaml:"instance_profile,omitempty"`
|
||||
|
||||
SecurityGroup []string `json:"securityGroup,omitempty" yaml:"security_group,omitempty"`
|
||||
|
||||
Url string `json:"url,omitempty" yaml:"url,omitempty"`
|
||||
}
|
||||
|
||||
type ExoscaleConfigCollection struct {
|
||||
Collection
|
||||
Data []ExoscaleConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type ExoscaleConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type ExoscaleConfigOperations interface {
|
||||
List(opts *ListOpts) (*ExoscaleConfigCollection, error)
|
||||
Create(opts *ExoscaleConfig) (*ExoscaleConfig, error)
|
||||
Update(existing *ExoscaleConfig, updates interface{}) (*ExoscaleConfig, error)
|
||||
ById(id string) (*ExoscaleConfig, error)
|
||||
Delete(container *ExoscaleConfig) error
|
||||
}
|
||||
|
||||
func newExoscaleConfigClient(rancherClient *RancherClient) *ExoscaleConfigClient {
|
||||
return &ExoscaleConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ExoscaleConfigClient) Create(container *ExoscaleConfig) (*ExoscaleConfig, error) {
|
||||
resp := &ExoscaleConfig{}
|
||||
err := c.rancherClient.doCreate(EXOSCALE_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExoscaleConfigClient) Update(existing *ExoscaleConfig, updates interface{}) (*ExoscaleConfig, error) {
|
||||
resp := &ExoscaleConfig{}
|
||||
err := c.rancherClient.doUpdate(EXOSCALE_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExoscaleConfigClient) List(opts *ListOpts) (*ExoscaleConfigCollection, error) {
|
||||
resp := &ExoscaleConfigCollection{}
|
||||
err := c.rancherClient.doList(EXOSCALE_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExoscaleConfigClient) ById(id string) (*ExoscaleConfig, error) {
|
||||
resp := &ExoscaleConfig{}
|
||||
err := c.rancherClient.doById(EXOSCALE_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *ExoscaleConfigClient) Delete(container *ExoscaleConfig) error {
|
||||
return c.rancherClient.doResourceDelete(EXOSCALE_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
GITHUBCONFIG_TYPE = "githubconfig"
|
||||
)
|
||||
|
||||
type Githubconfig struct {
|
||||
Resource
|
||||
|
||||
AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"`
|
||||
|
||||
AllowedIdentities []interface{} `json:"allowedIdentities,omitempty" yaml:"allowed_identities,omitempty"`
|
||||
|
||||
ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"`
|
||||
|
||||
ClientSecret string `json:"clientSecret,omitempty" yaml:"client_secret,omitempty"`
|
||||
|
||||
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
|
||||
|
||||
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
|
||||
}
|
||||
|
||||
type GithubconfigCollection struct {
|
||||
Collection
|
||||
Data []Githubconfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type GithubconfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type GithubconfigOperations interface {
|
||||
List(opts *ListOpts) (*GithubconfigCollection, error)
|
||||
Create(opts *Githubconfig) (*Githubconfig, error)
|
||||
Update(existing *Githubconfig, updates interface{}) (*Githubconfig, error)
|
||||
ById(id string) (*Githubconfig, error)
|
||||
Delete(container *Githubconfig) error
|
||||
}
|
||||
|
||||
func newGithubconfigClient(rancherClient *RancherClient) *GithubconfigClient {
|
||||
return &GithubconfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *GithubconfigClient) Create(container *Githubconfig) (*Githubconfig, error) {
|
||||
resp := &Githubconfig{}
|
||||
err := c.rancherClient.doCreate(GITHUBCONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GithubconfigClient) Update(existing *Githubconfig, updates interface{}) (*Githubconfig, error) {
|
||||
resp := &Githubconfig{}
|
||||
err := c.rancherClient.doUpdate(GITHUBCONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GithubconfigClient) List(opts *ListOpts) (*GithubconfigCollection, error) {
|
||||
resp := &GithubconfigCollection{}
|
||||
err := c.rancherClient.doList(GITHUBCONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GithubconfigClient) ById(id string) (*Githubconfig, error) {
|
||||
resp := &Githubconfig{}
|
||||
err := c.rancherClient.doById(GITHUBCONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GithubconfigClient) Delete(container *Githubconfig) error {
|
||||
return c.rancherClient.doResourceDelete(GITHUBCONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-139
@@ -1,139 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
GLOBAL_LOAD_BALANCER_TYPE = "globalLoadBalancer"
|
||||
)
|
||||
|
||||
type GlobalLoadBalancer 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"`
|
||||
|
||||
GlobalLoadBalancerHealthCheck []interface{} `json:"globalLoadBalancerHealthCheck,omitempty" yaml:"global_load_balancer_health_check,omitempty"`
|
||||
|
||||
GlobalLoadBalancerPolicy []interface{} `json:"globalLoadBalancerPolicy,omitempty" yaml:"global_load_balancer_policy,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 GlobalLoadBalancerCollection struct {
|
||||
Collection
|
||||
Data []GlobalLoadBalancer `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerOperations interface {
|
||||
List(opts *ListOpts) (*GlobalLoadBalancerCollection, error)
|
||||
Create(opts *GlobalLoadBalancer) (*GlobalLoadBalancer, error)
|
||||
Update(existing *GlobalLoadBalancer, updates interface{}) (*GlobalLoadBalancer, error)
|
||||
ById(id string) (*GlobalLoadBalancer, error)
|
||||
Delete(container *GlobalLoadBalancer) error
|
||||
|
||||
ActionAddloadbalancer(*GlobalLoadBalancer, *AddLoadBalancerInput) (*GlobalLoadBalancer, error)
|
||||
|
||||
ActionCreate(*GlobalLoadBalancer) (*GlobalLoadBalancer, error)
|
||||
|
||||
ActionRemove(*GlobalLoadBalancer) (*GlobalLoadBalancer, error)
|
||||
|
||||
ActionRemoveloadbalancer(*GlobalLoadBalancer, *RemoveLoadBalancerInput) (*GlobalLoadBalancer, error)
|
||||
}
|
||||
|
||||
func newGlobalLoadBalancerClient(rancherClient *RancherClient) *GlobalLoadBalancerClient {
|
||||
return &GlobalLoadBalancerClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) Create(container *GlobalLoadBalancer) (*GlobalLoadBalancer, error) {
|
||||
resp := &GlobalLoadBalancer{}
|
||||
err := c.rancherClient.doCreate(GLOBAL_LOAD_BALANCER_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) Update(existing *GlobalLoadBalancer, updates interface{}) (*GlobalLoadBalancer, error) {
|
||||
resp := &GlobalLoadBalancer{}
|
||||
err := c.rancherClient.doUpdate(GLOBAL_LOAD_BALANCER_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) List(opts *ListOpts) (*GlobalLoadBalancerCollection, error) {
|
||||
resp := &GlobalLoadBalancerCollection{}
|
||||
err := c.rancherClient.doList(GLOBAL_LOAD_BALANCER_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) ById(id string) (*GlobalLoadBalancer, error) {
|
||||
resp := &GlobalLoadBalancer{}
|
||||
err := c.rancherClient.doById(GLOBAL_LOAD_BALANCER_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) Delete(container *GlobalLoadBalancer) error {
|
||||
return c.rancherClient.doResourceDelete(GLOBAL_LOAD_BALANCER_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) ActionAddloadbalancer(resource *GlobalLoadBalancer, input *AddLoadBalancerInput) (*GlobalLoadBalancer, error) {
|
||||
|
||||
resp := &GlobalLoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "addloadbalancer", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) ActionCreate(resource *GlobalLoadBalancer) (*GlobalLoadBalancer, error) {
|
||||
|
||||
resp := &GlobalLoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) ActionRemove(resource *GlobalLoadBalancer) (*GlobalLoadBalancer, error) {
|
||||
|
||||
resp := &GlobalLoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerClient) ActionRemoveloadbalancer(resource *GlobalLoadBalancer, input *RemoveLoadBalancerInput) (*GlobalLoadBalancer, error) {
|
||||
|
||||
resp := &GlobalLoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(GLOBAL_LOAD_BALANCER_TYPE, "removeloadbalancer", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE = "globalLoadBalancerHealthCheck"
|
||||
)
|
||||
|
||||
type GlobalLoadBalancerHealthCheck struct {
|
||||
Resource
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerHealthCheckCollection struct {
|
||||
Collection
|
||||
Data []GlobalLoadBalancerHealthCheck `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerHealthCheckClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerHealthCheckOperations interface {
|
||||
List(opts *ListOpts) (*GlobalLoadBalancerHealthCheckCollection, error)
|
||||
Create(opts *GlobalLoadBalancerHealthCheck) (*GlobalLoadBalancerHealthCheck, error)
|
||||
Update(existing *GlobalLoadBalancerHealthCheck, updates interface{}) (*GlobalLoadBalancerHealthCheck, error)
|
||||
ById(id string) (*GlobalLoadBalancerHealthCheck, error)
|
||||
Delete(container *GlobalLoadBalancerHealthCheck) error
|
||||
}
|
||||
|
||||
func newGlobalLoadBalancerHealthCheckClient(rancherClient *RancherClient) *GlobalLoadBalancerHealthCheckClient {
|
||||
return &GlobalLoadBalancerHealthCheckClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerHealthCheckClient) Create(container *GlobalLoadBalancerHealthCheck) (*GlobalLoadBalancerHealthCheck, error) {
|
||||
resp := &GlobalLoadBalancerHealthCheck{}
|
||||
err := c.rancherClient.doCreate(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerHealthCheckClient) Update(existing *GlobalLoadBalancerHealthCheck, updates interface{}) (*GlobalLoadBalancerHealthCheck, error) {
|
||||
resp := &GlobalLoadBalancerHealthCheck{}
|
||||
err := c.rancherClient.doUpdate(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerHealthCheckClient) List(opts *ListOpts) (*GlobalLoadBalancerHealthCheckCollection, error) {
|
||||
resp := &GlobalLoadBalancerHealthCheckCollection{}
|
||||
err := c.rancherClient.doList(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerHealthCheckClient) ById(id string) (*GlobalLoadBalancerHealthCheck, error) {
|
||||
resp := &GlobalLoadBalancerHealthCheck{}
|
||||
err := c.rancherClient.doById(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerHealthCheckClient) Delete(container *GlobalLoadBalancerHealthCheck) error {
|
||||
return c.rancherClient.doResourceDelete(GLOBAL_LOAD_BALANCER_HEALTH_CHECK_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
GLOBAL_LOAD_BALANCER_POLICY_TYPE = "globalLoadBalancerPolicy"
|
||||
)
|
||||
|
||||
type GlobalLoadBalancerPolicy struct {
|
||||
Resource
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerPolicyCollection struct {
|
||||
Collection
|
||||
Data []GlobalLoadBalancerPolicy `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerPolicyClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type GlobalLoadBalancerPolicyOperations interface {
|
||||
List(opts *ListOpts) (*GlobalLoadBalancerPolicyCollection, error)
|
||||
Create(opts *GlobalLoadBalancerPolicy) (*GlobalLoadBalancerPolicy, error)
|
||||
Update(existing *GlobalLoadBalancerPolicy, updates interface{}) (*GlobalLoadBalancerPolicy, error)
|
||||
ById(id string) (*GlobalLoadBalancerPolicy, error)
|
||||
Delete(container *GlobalLoadBalancerPolicy) error
|
||||
}
|
||||
|
||||
func newGlobalLoadBalancerPolicyClient(rancherClient *RancherClient) *GlobalLoadBalancerPolicyClient {
|
||||
return &GlobalLoadBalancerPolicyClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerPolicyClient) Create(container *GlobalLoadBalancerPolicy) (*GlobalLoadBalancerPolicy, error) {
|
||||
resp := &GlobalLoadBalancerPolicy{}
|
||||
err := c.rancherClient.doCreate(GLOBAL_LOAD_BALANCER_POLICY_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerPolicyClient) Update(existing *GlobalLoadBalancerPolicy, updates interface{}) (*GlobalLoadBalancerPolicy, error) {
|
||||
resp := &GlobalLoadBalancerPolicy{}
|
||||
err := c.rancherClient.doUpdate(GLOBAL_LOAD_BALANCER_POLICY_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerPolicyClient) List(opts *ListOpts) (*GlobalLoadBalancerPolicyCollection, error) {
|
||||
resp := &GlobalLoadBalancerPolicyCollection{}
|
||||
err := c.rancherClient.doList(GLOBAL_LOAD_BALANCER_POLICY_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerPolicyClient) ById(id string) (*GlobalLoadBalancerPolicy, error) {
|
||||
resp := &GlobalLoadBalancerPolicy{}
|
||||
err := c.rancherClient.doById(GLOBAL_LOAD_BALANCER_POLICY_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *GlobalLoadBalancerPolicyClient) Delete(container *GlobalLoadBalancerPolicy) error {
|
||||
return c.rancherClient.doResourceDelete(GLOBAL_LOAD_BALANCER_POLICY_TYPE, &container.Resource)
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
HAPROXY_CONFIG_TYPE = "haproxyConfig"
|
||||
)
|
||||
|
||||
type HaproxyConfig struct {
|
||||
Resource
|
||||
|
||||
Defaults string `json:"defaults,omitempty" yaml:"defaults,omitempty"`
|
||||
|
||||
Global string `json:"global,omitempty" yaml:"global,omitempty"`
|
||||
}
|
||||
|
||||
type HaproxyConfigCollection struct {
|
||||
Collection
|
||||
Data []HaproxyConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type HaproxyConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type HaproxyConfigOperations interface {
|
||||
List(opts *ListOpts) (*HaproxyConfigCollection, error)
|
||||
Create(opts *HaproxyConfig) (*HaproxyConfig, error)
|
||||
Update(existing *HaproxyConfig, updates interface{}) (*HaproxyConfig, error)
|
||||
ById(id string) (*HaproxyConfig, error)
|
||||
Delete(container *HaproxyConfig) error
|
||||
}
|
||||
|
||||
func newHaproxyConfigClient(rancherClient *RancherClient) *HaproxyConfigClient {
|
||||
return &HaproxyConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HaproxyConfigClient) Create(container *HaproxyConfig) (*HaproxyConfig, error) {
|
||||
resp := &HaproxyConfig{}
|
||||
err := c.rancherClient.doCreate(HAPROXY_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *HaproxyConfigClient) Update(existing *HaproxyConfig, updates interface{}) (*HaproxyConfig, error) {
|
||||
resp := &HaproxyConfig{}
|
||||
err := c.rancherClient.doUpdate(HAPROXY_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *HaproxyConfigClient) List(opts *ListOpts) (*HaproxyConfigCollection, error) {
|
||||
resp := &HaproxyConfigCollection{}
|
||||
err := c.rancherClient.doList(HAPROXY_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *HaproxyConfigClient) ById(id string) (*HaproxyConfig, error) {
|
||||
resp := &HaproxyConfig{}
|
||||
err := c.rancherClient.doById(HAPROXY_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *HaproxyConfigClient) Delete(container *HaproxyConfig) error {
|
||||
return c.rancherClient.doResourceDelete(HAPROXY_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
IP_ADDRESS_ASSOCIATE_INPUT_TYPE = "ipAddressAssociateInput"
|
||||
)
|
||||
|
||||
type IpAddressAssociateInput struct {
|
||||
Resource
|
||||
|
||||
IpAddressId string `json:"ipAddressId,omitempty" yaml:"ip_address_id,omitempty"`
|
||||
}
|
||||
|
||||
type IpAddressAssociateInputCollection struct {
|
||||
Collection
|
||||
Data []IpAddressAssociateInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type IpAddressAssociateInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type IpAddressAssociateInputOperations interface {
|
||||
List(opts *ListOpts) (*IpAddressAssociateInputCollection, error)
|
||||
Create(opts *IpAddressAssociateInput) (*IpAddressAssociateInput, error)
|
||||
Update(existing *IpAddressAssociateInput, updates interface{}) (*IpAddressAssociateInput, error)
|
||||
ById(id string) (*IpAddressAssociateInput, error)
|
||||
Delete(container *IpAddressAssociateInput) error
|
||||
}
|
||||
|
||||
func newIpAddressAssociateInputClient(rancherClient *RancherClient) *IpAddressAssociateInputClient {
|
||||
return &IpAddressAssociateInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *IpAddressAssociateInputClient) Create(container *IpAddressAssociateInput) (*IpAddressAssociateInput, error) {
|
||||
resp := &IpAddressAssociateInput{}
|
||||
err := c.rancherClient.doCreate(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *IpAddressAssociateInputClient) Update(existing *IpAddressAssociateInput, updates interface{}) (*IpAddressAssociateInput, error) {
|
||||
resp := &IpAddressAssociateInput{}
|
||||
err := c.rancherClient.doUpdate(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *IpAddressAssociateInputClient) List(opts *ListOpts) (*IpAddressAssociateInputCollection, error) {
|
||||
resp := &IpAddressAssociateInputCollection{}
|
||||
err := c.rancherClient.doList(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *IpAddressAssociateInputClient) ById(id string) (*IpAddressAssociateInput, error) {
|
||||
resp := &IpAddressAssociateInput{}
|
||||
err := c.rancherClient.doById(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *IpAddressAssociateInputClient) Delete(container *IpAddressAssociateInput) error {
|
||||
return c.rancherClient.doResourceDelete(IP_ADDRESS_ASSOCIATE_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LDAPCONFIG_TYPE = "ldapconfig"
|
||||
)
|
||||
|
||||
type Ldapconfig struct {
|
||||
Resource
|
||||
|
||||
AccessMode string `json:"accessMode,omitempty" yaml:"access_mode,omitempty"`
|
||||
|
||||
ConnectionTimeout int64 `json:"connectionTimeout,omitempty" yaml:"connection_timeout,omitempty"`
|
||||
|
||||
Domain string `json:"domain,omitempty" yaml:"domain,omitempty"`
|
||||
|
||||
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
|
||||
|
||||
GroupMemberMappingAttribute string `json:"groupMemberMappingAttribute,omitempty" yaml:"group_member_mapping_attribute,omitempty"`
|
||||
|
||||
GroupNameField string `json:"groupNameField,omitempty" yaml:"group_name_field,omitempty"`
|
||||
|
||||
GroupObjectClass string `json:"groupObjectClass,omitempty" yaml:"group_object_class,omitempty"`
|
||||
|
||||
GroupSearchField string `json:"groupSearchField,omitempty" yaml:"group_search_field,omitempty"`
|
||||
|
||||
LoginDomain string `json:"loginDomain,omitempty" yaml:"login_domain,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
|
||||
Server string `json:"server,omitempty" yaml:"server,omitempty"`
|
||||
|
||||
ServiceAccountPassword string `json:"serviceAccountPassword,omitempty" yaml:"service_account_password,omitempty"`
|
||||
|
||||
ServiceAccountUsername string `json:"serviceAccountUsername,omitempty" yaml:"service_account_username,omitempty"`
|
||||
|
||||
Tls bool `json:"tls,omitempty" yaml:"tls,omitempty"`
|
||||
|
||||
UserDisabledBitMask int64 `json:"userDisabledBitMask,omitempty" yaml:"user_disabled_bit_mask,omitempty"`
|
||||
|
||||
UserEnabledAttribute string `json:"userEnabledAttribute,omitempty" yaml:"user_enabled_attribute,omitempty"`
|
||||
|
||||
UserLoginField string `json:"userLoginField,omitempty" yaml:"user_login_field,omitempty"`
|
||||
|
||||
UserMemberAttribute string `json:"userMemberAttribute,omitempty" yaml:"user_member_attribute,omitempty"`
|
||||
|
||||
UserNameField string `json:"userNameField,omitempty" yaml:"user_name_field,omitempty"`
|
||||
|
||||
UserObjectClass string `json:"userObjectClass,omitempty" yaml:"user_object_class,omitempty"`
|
||||
|
||||
UserSearchField string `json:"userSearchField,omitempty" yaml:"user_search_field,omitempty"`
|
||||
}
|
||||
|
||||
type LdapconfigCollection struct {
|
||||
Collection
|
||||
Data []Ldapconfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LdapconfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LdapconfigOperations interface {
|
||||
List(opts *ListOpts) (*LdapconfigCollection, error)
|
||||
Create(opts *Ldapconfig) (*Ldapconfig, error)
|
||||
Update(existing *Ldapconfig, updates interface{}) (*Ldapconfig, error)
|
||||
ById(id string) (*Ldapconfig, error)
|
||||
Delete(container *Ldapconfig) error
|
||||
}
|
||||
|
||||
func newLdapconfigClient(rancherClient *RancherClient) *LdapconfigClient {
|
||||
return &LdapconfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LdapconfigClient) Create(container *Ldapconfig) (*Ldapconfig, error) {
|
||||
resp := &Ldapconfig{}
|
||||
err := c.rancherClient.doCreate(LDAPCONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LdapconfigClient) Update(existing *Ldapconfig, updates interface{}) (*Ldapconfig, error) {
|
||||
resp := &Ldapconfig{}
|
||||
err := c.rancherClient.doUpdate(LDAPCONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LdapconfigClient) List(opts *ListOpts) (*LdapconfigCollection, error) {
|
||||
resp := &LdapconfigCollection{}
|
||||
err := c.rancherClient.doList(LDAPCONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LdapconfigClient) ById(id string) (*Ldapconfig, error) {
|
||||
resp := &Ldapconfig{}
|
||||
err := c.rancherClient.doById(LDAPCONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LdapconfigClient) Delete(container *Ldapconfig) error {
|
||||
return c.rancherClient.doResourceDelete(LDAPCONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-224
@@ -1,224 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_TYPE = "loadBalancer"
|
||||
)
|
||||
|
||||
type LoadBalancer struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
CertificateIds []string `json:"certificateIds,omitempty" yaml:"certificate_ids,omitempty"`
|
||||
|
||||
Created string `json:"created,omitempty" yaml:"created,omitempty"`
|
||||
|
||||
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
|
||||
|
||||
DefaultCertificateId string `json:"defaultCertificateId,omitempty" yaml:"default_certificate_id,omitempty"`
|
||||
|
||||
Description string `json:"description,omitempty" yaml:"description,omitempty"`
|
||||
|
||||
GlobalLoadBalancerId string `json:"globalLoadBalancerId,omitempty" yaml:"global_load_balancer_id,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
LoadBalancerConfigId string `json:"loadBalancerConfigId,omitempty" yaml:"load_balancer_config_id,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"`
|
||||
|
||||
ServiceId string `json:"serviceId,omitempty" yaml:"service_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"`
|
||||
|
||||
Weight int64 `json:"weight,omitempty" yaml:"weight,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancer `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerCollection, error)
|
||||
Create(opts *LoadBalancer) (*LoadBalancer, error)
|
||||
Update(existing *LoadBalancer, updates interface{}) (*LoadBalancer, error)
|
||||
ById(id string) (*LoadBalancer, error)
|
||||
Delete(container *LoadBalancer) error
|
||||
|
||||
ActionActivate(*LoadBalancer) (*LoadBalancer, error)
|
||||
|
||||
ActionAddhost(*LoadBalancer, *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error)
|
||||
|
||||
ActionAddtarget(*LoadBalancer, *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error)
|
||||
|
||||
ActionCreate(*LoadBalancer) (*LoadBalancer, error)
|
||||
|
||||
ActionDeactivate(*LoadBalancer) (*LoadBalancer, error)
|
||||
|
||||
ActionRemove(*LoadBalancer) (*LoadBalancer, error)
|
||||
|
||||
ActionRemovehost(*LoadBalancer, *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error)
|
||||
|
||||
ActionRemovetarget(*LoadBalancer, *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error)
|
||||
|
||||
ActionSethosts(*LoadBalancer, *SetLoadBalancerHostsInput) (*LoadBalancer, error)
|
||||
|
||||
ActionSettargets(*LoadBalancer, *SetLoadBalancerTargetsInput) (*LoadBalancer, error)
|
||||
|
||||
ActionUpdate(*LoadBalancer) (*LoadBalancer, error)
|
||||
}
|
||||
|
||||
func newLoadBalancerClient(rancherClient *RancherClient) *LoadBalancerClient {
|
||||
return &LoadBalancerClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) Create(container *LoadBalancer) (*LoadBalancer, error) {
|
||||
resp := &LoadBalancer{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) Update(existing *LoadBalancer, updates interface{}) (*LoadBalancer, error) {
|
||||
resp := &LoadBalancer{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) List(opts *ListOpts) (*LoadBalancerCollection, error) {
|
||||
resp := &LoadBalancerCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ById(id string) (*LoadBalancer, error) {
|
||||
resp := &LoadBalancer{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) Delete(container *LoadBalancer) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionActivate(resource *LoadBalancer) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "activate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionAddhost(resource *LoadBalancer, input *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "addhost", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionAddtarget(resource *LoadBalancer, input *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "addtarget", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionCreate(resource *LoadBalancer) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionDeactivate(resource *LoadBalancer) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "deactivate", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionRemove(resource *LoadBalancer) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionRemovehost(resource *LoadBalancer, input *AddRemoveLoadBalancerHostInput) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "removehost", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionRemovetarget(resource *LoadBalancer, input *AddRemoveLoadBalancerTargetInput) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "removetarget", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionSethosts(resource *LoadBalancer, input *SetLoadBalancerHostsInput) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "sethosts", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionSettargets(resource *LoadBalancer, input *SetLoadBalancerTargetsInput) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "settargets", &resource.Resource, input, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerClient) ActionUpdate(resource *LoadBalancer) (*LoadBalancer, error) {
|
||||
|
||||
resp := &LoadBalancer{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Generated
Vendored
-79
@@ -1,79 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE = "loadBalancerAppCookieStickinessPolicy"
|
||||
)
|
||||
|
||||
type LoadBalancerAppCookieStickinessPolicy struct {
|
||||
Resource
|
||||
|
||||
Cookie string `json:"cookie,omitempty" yaml:"cookie,omitempty"`
|
||||
|
||||
MaxLength int64 `json:"maxLength,omitempty" yaml:"max_length,omitempty"`
|
||||
|
||||
Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Prefix bool `json:"prefix,omitempty" yaml:"prefix,omitempty"`
|
||||
|
||||
RequestLearn bool `json:"requestLearn,omitempty" yaml:"request_learn,omitempty"`
|
||||
|
||||
Timeout int64 `json:"timeout,omitempty" yaml:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerAppCookieStickinessPolicyCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerAppCookieStickinessPolicy `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerAppCookieStickinessPolicyClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerAppCookieStickinessPolicyOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerAppCookieStickinessPolicyCollection, error)
|
||||
Create(opts *LoadBalancerAppCookieStickinessPolicy) (*LoadBalancerAppCookieStickinessPolicy, error)
|
||||
Update(existing *LoadBalancerAppCookieStickinessPolicy, updates interface{}) (*LoadBalancerAppCookieStickinessPolicy, error)
|
||||
ById(id string) (*LoadBalancerAppCookieStickinessPolicy, error)
|
||||
Delete(container *LoadBalancerAppCookieStickinessPolicy) error
|
||||
}
|
||||
|
||||
func newLoadBalancerAppCookieStickinessPolicyClient(rancherClient *RancherClient) *LoadBalancerAppCookieStickinessPolicyClient {
|
||||
return &LoadBalancerAppCookieStickinessPolicyClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerAppCookieStickinessPolicyClient) Create(container *LoadBalancerAppCookieStickinessPolicy) (*LoadBalancerAppCookieStickinessPolicy, error) {
|
||||
resp := &LoadBalancerAppCookieStickinessPolicy{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerAppCookieStickinessPolicyClient) Update(existing *LoadBalancerAppCookieStickinessPolicy, updates interface{}) (*LoadBalancerAppCookieStickinessPolicy, error) {
|
||||
resp := &LoadBalancerAppCookieStickinessPolicy{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerAppCookieStickinessPolicyClient) List(opts *ListOpts) (*LoadBalancerAppCookieStickinessPolicyCollection, error) {
|
||||
resp := &LoadBalancerAppCookieStickinessPolicyCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerAppCookieStickinessPolicyClient) ById(id string) (*LoadBalancerAppCookieStickinessPolicy, error) {
|
||||
resp := &LoadBalancerAppCookieStickinessPolicy{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerAppCookieStickinessPolicyClient) Delete(container *LoadBalancerAppCookieStickinessPolicy) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_APP_COOKIE_STICKINESS_POLICY_TYPE, &container.Resource)
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_CONFIG_TYPE = "loadBalancerConfig"
|
||||
)
|
||||
|
||||
type LoadBalancerConfig struct {
|
||||
Resource
|
||||
|
||||
HaproxyConfig *HaproxyConfig `json:"haproxyConfig,omitempty" yaml:"haproxy_config,omitempty"`
|
||||
|
||||
LbCookieStickinessPolicy *LoadBalancerCookieStickinessPolicy `json:"lbCookieStickinessPolicy,omitempty" yaml:"lb_cookie_stickiness_policy,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerConfigCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerConfigOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerConfigCollection, error)
|
||||
Create(opts *LoadBalancerConfig) (*LoadBalancerConfig, error)
|
||||
Update(existing *LoadBalancerConfig, updates interface{}) (*LoadBalancerConfig, error)
|
||||
ById(id string) (*LoadBalancerConfig, error)
|
||||
Delete(container *LoadBalancerConfig) error
|
||||
}
|
||||
|
||||
func newLoadBalancerConfigClient(rancherClient *RancherClient) *LoadBalancerConfigClient {
|
||||
return &LoadBalancerConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigClient) Create(container *LoadBalancerConfig) (*LoadBalancerConfig, error) {
|
||||
resp := &LoadBalancerConfig{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigClient) Update(existing *LoadBalancerConfig, updates interface{}) (*LoadBalancerConfig, error) {
|
||||
resp := &LoadBalancerConfig{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigClient) List(opts *ListOpts) (*LoadBalancerConfigCollection, error) {
|
||||
resp := &LoadBalancerConfigCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigClient) ById(id string) (*LoadBalancerConfig, error) {
|
||||
resp := &LoadBalancerConfig{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigClient) Delete(container *LoadBalancerConfig) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-117
@@ -1,117 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE = "loadBalancerConfigListenerMap"
|
||||
)
|
||||
|
||||
type LoadBalancerConfigListenerMap 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"`
|
||||
|
||||
LoadBalancerConfigId string `json:"loadBalancerConfigId,omitempty" yaml:"load_balancer_config_id,omitempty"`
|
||||
|
||||
LoadBalancerListenerId string `json:"loadBalancerListenerId,omitempty" yaml:"load_balancer_listener_id,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 LoadBalancerConfigListenerMapCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerConfigListenerMap `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerConfigListenerMapClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerConfigListenerMapOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerConfigListenerMapCollection, error)
|
||||
Create(opts *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error)
|
||||
Update(existing *LoadBalancerConfigListenerMap, updates interface{}) (*LoadBalancerConfigListenerMap, error)
|
||||
ById(id string) (*LoadBalancerConfigListenerMap, error)
|
||||
Delete(container *LoadBalancerConfigListenerMap) error
|
||||
|
||||
ActionCreate(*LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error)
|
||||
|
||||
ActionRemove(*LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error)
|
||||
}
|
||||
|
||||
func newLoadBalancerConfigListenerMapClient(rancherClient *RancherClient) *LoadBalancerConfigListenerMapClient {
|
||||
return &LoadBalancerConfigListenerMapClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigListenerMapClient) Create(container *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) {
|
||||
resp := &LoadBalancerConfigListenerMap{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigListenerMapClient) Update(existing *LoadBalancerConfigListenerMap, updates interface{}) (*LoadBalancerConfigListenerMap, error) {
|
||||
resp := &LoadBalancerConfigListenerMap{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigListenerMapClient) List(opts *ListOpts) (*LoadBalancerConfigListenerMapCollection, error) {
|
||||
resp := &LoadBalancerConfigListenerMapCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigListenerMapClient) ById(id string) (*LoadBalancerConfigListenerMap, error) {
|
||||
resp := &LoadBalancerConfigListenerMap{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigListenerMapClient) Delete(container *LoadBalancerConfigListenerMap) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigListenerMapClient) ActionCreate(resource *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) {
|
||||
|
||||
resp := &LoadBalancerConfigListenerMap{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerConfigListenerMapClient) ActionRemove(resource *LoadBalancerConfigListenerMap) (*LoadBalancerConfigListenerMap, error) {
|
||||
|
||||
resp := &LoadBalancerConfigListenerMap{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_CONFIG_LISTENER_MAP_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Generated
Vendored
-79
@@ -1,79 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_HEALTH_CHECK_TYPE = "loadBalancerHealthCheck"
|
||||
)
|
||||
|
||||
type LoadBalancerHealthCheck struct {
|
||||
Resource
|
||||
|
||||
HealthyThreshold int64 `json:"healthyThreshold,omitempty" yaml:"healthy_threshold,omitempty"`
|
||||
|
||||
Interval int64 `json:"interval,omitempty" yaml:"interval,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Port int64 `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
|
||||
RequestLine string `json:"requestLine,omitempty" yaml:"request_line,omitempty"`
|
||||
|
||||
ResponseTimeout int64 `json:"responseTimeout,omitempty" yaml:"response_timeout,omitempty"`
|
||||
|
||||
UnhealthyThreshold int64 `json:"unhealthyThreshold,omitempty" yaml:"unhealthy_threshold,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerHealthCheckCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerHealthCheck `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerHealthCheckClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerHealthCheckOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerHealthCheckCollection, error)
|
||||
Create(opts *LoadBalancerHealthCheck) (*LoadBalancerHealthCheck, error)
|
||||
Update(existing *LoadBalancerHealthCheck, updates interface{}) (*LoadBalancerHealthCheck, error)
|
||||
ById(id string) (*LoadBalancerHealthCheck, error)
|
||||
Delete(container *LoadBalancerHealthCheck) error
|
||||
}
|
||||
|
||||
func newLoadBalancerHealthCheckClient(rancherClient *RancherClient) *LoadBalancerHealthCheckClient {
|
||||
return &LoadBalancerHealthCheckClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHealthCheckClient) Create(container *LoadBalancerHealthCheck) (*LoadBalancerHealthCheck, error) {
|
||||
resp := &LoadBalancerHealthCheck{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_HEALTH_CHECK_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHealthCheckClient) Update(existing *LoadBalancerHealthCheck, updates interface{}) (*LoadBalancerHealthCheck, error) {
|
||||
resp := &LoadBalancerHealthCheck{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_HEALTH_CHECK_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHealthCheckClient) List(opts *ListOpts) (*LoadBalancerHealthCheckCollection, error) {
|
||||
resp := &LoadBalancerHealthCheckCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_HEALTH_CHECK_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHealthCheckClient) ById(id string) (*LoadBalancerHealthCheck, error) {
|
||||
resp := &LoadBalancerHealthCheck{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_HEALTH_CHECK_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHealthCheckClient) Delete(container *LoadBalancerHealthCheck) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_HEALTH_CHECK_TYPE, &container.Resource)
|
||||
}
|
||||
-89
@@ -1,89 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_HOST_MAP_TYPE = "loadBalancerHostMap"
|
||||
)
|
||||
|
||||
type LoadBalancerHostMap 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"`
|
||||
|
||||
HostId string `json:"hostId,omitempty" yaml:"host_id,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,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"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerHostMapCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerHostMap `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerHostMapClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerHostMapOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerHostMapCollection, error)
|
||||
Create(opts *LoadBalancerHostMap) (*LoadBalancerHostMap, error)
|
||||
Update(existing *LoadBalancerHostMap, updates interface{}) (*LoadBalancerHostMap, error)
|
||||
ById(id string) (*LoadBalancerHostMap, error)
|
||||
Delete(container *LoadBalancerHostMap) error
|
||||
}
|
||||
|
||||
func newLoadBalancerHostMapClient(rancherClient *RancherClient) *LoadBalancerHostMapClient {
|
||||
return &LoadBalancerHostMapClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHostMapClient) Create(container *LoadBalancerHostMap) (*LoadBalancerHostMap, error) {
|
||||
resp := &LoadBalancerHostMap{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_HOST_MAP_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHostMapClient) Update(existing *LoadBalancerHostMap, updates interface{}) (*LoadBalancerHostMap, error) {
|
||||
resp := &LoadBalancerHostMap{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_HOST_MAP_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHostMapClient) List(opts *ListOpts) (*LoadBalancerHostMapCollection, error) {
|
||||
resp := &LoadBalancerHostMapCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_HOST_MAP_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHostMapClient) ById(id string) (*LoadBalancerHostMap, error) {
|
||||
resp := &LoadBalancerHostMap{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_HOST_MAP_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerHostMapClient) Delete(container *LoadBalancerHostMap) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_HOST_MAP_TYPE, &container.Resource)
|
||||
}
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_LISTENER_TYPE = "loadBalancerListener"
|
||||
)
|
||||
|
||||
type LoadBalancerListener struct {
|
||||
Resource
|
||||
|
||||
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
|
||||
|
||||
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,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"`
|
||||
|
||||
PrivatePort int64 `json:"privatePort,omitempty" yaml:"private_port,omitempty"`
|
||||
|
||||
RemoveTime string `json:"removeTime,omitempty" yaml:"remove_time,omitempty"`
|
||||
|
||||
Removed string `json:"removed,omitempty" yaml:"removed,omitempty"`
|
||||
|
||||
ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"`
|
||||
|
||||
SourcePort int64 `json:"sourcePort,omitempty" yaml:"source_port,omitempty"`
|
||||
|
||||
SourceProtocol string `json:"sourceProtocol,omitempty" yaml:"source_protocol,omitempty"`
|
||||
|
||||
State string `json:"state,omitempty" yaml:"state,omitempty"`
|
||||
|
||||
TargetPort int64 `json:"targetPort,omitempty" yaml:"target_port,omitempty"`
|
||||
|
||||
TargetProtocol string `json:"targetProtocol,omitempty" yaml:"target_protocol,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 LoadBalancerListenerCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerListener `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerListenerClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerListenerOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerListenerCollection, error)
|
||||
Create(opts *LoadBalancerListener) (*LoadBalancerListener, error)
|
||||
Update(existing *LoadBalancerListener, updates interface{}) (*LoadBalancerListener, error)
|
||||
ById(id string) (*LoadBalancerListener, error)
|
||||
Delete(container *LoadBalancerListener) error
|
||||
|
||||
ActionCreate(*LoadBalancerListener) (*LoadBalancerListener, error)
|
||||
|
||||
ActionRemove(*LoadBalancerListener) (*LoadBalancerListener, error)
|
||||
}
|
||||
|
||||
func newLoadBalancerListenerClient(rancherClient *RancherClient) *LoadBalancerListenerClient {
|
||||
return &LoadBalancerListenerClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerListenerClient) Create(container *LoadBalancerListener) (*LoadBalancerListener, error) {
|
||||
resp := &LoadBalancerListener{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_LISTENER_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerListenerClient) Update(existing *LoadBalancerListener, updates interface{}) (*LoadBalancerListener, error) {
|
||||
resp := &LoadBalancerListener{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_LISTENER_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerListenerClient) List(opts *ListOpts) (*LoadBalancerListenerCollection, error) {
|
||||
resp := &LoadBalancerListenerCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_LISTENER_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerListenerClient) ById(id string) (*LoadBalancerListener, error) {
|
||||
resp := &LoadBalancerListener{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_LISTENER_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerListenerClient) Delete(container *LoadBalancerListener) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_LISTENER_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *LoadBalancerListenerClient) ActionCreate(resource *LoadBalancerListener) (*LoadBalancerListener, error) {
|
||||
|
||||
resp := &LoadBalancerListener{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_LISTENER_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerListenerClient) ActionRemove(resource *LoadBalancerListener) (*LoadBalancerListener, error) {
|
||||
|
||||
resp := &LoadBalancerListener{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_LISTENER_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Generated
Vendored
-71
@@ -1,71 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_SERVICE_LINK_TYPE = "loadBalancerServiceLink"
|
||||
)
|
||||
|
||||
type LoadBalancerServiceLink struct {
|
||||
Resource
|
||||
|
||||
Ports []string `json:"ports,omitempty" yaml:"ports,omitempty"`
|
||||
|
||||
ServiceId string `json:"serviceId,omitempty" yaml:"service_id,omitempty"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" yaml:"uuid,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerServiceLinkCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerServiceLink `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerServiceLinkClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerServiceLinkOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerServiceLinkCollection, error)
|
||||
Create(opts *LoadBalancerServiceLink) (*LoadBalancerServiceLink, error)
|
||||
Update(existing *LoadBalancerServiceLink, updates interface{}) (*LoadBalancerServiceLink, error)
|
||||
ById(id string) (*LoadBalancerServiceLink, error)
|
||||
Delete(container *LoadBalancerServiceLink) error
|
||||
}
|
||||
|
||||
func newLoadBalancerServiceLinkClient(rancherClient *RancherClient) *LoadBalancerServiceLinkClient {
|
||||
return &LoadBalancerServiceLinkClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerServiceLinkClient) Create(container *LoadBalancerServiceLink) (*LoadBalancerServiceLink, error) {
|
||||
resp := &LoadBalancerServiceLink{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_SERVICE_LINK_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerServiceLinkClient) Update(existing *LoadBalancerServiceLink, updates interface{}) (*LoadBalancerServiceLink, error) {
|
||||
resp := &LoadBalancerServiceLink{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_SERVICE_LINK_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerServiceLinkClient) List(opts *ListOpts) (*LoadBalancerServiceLinkCollection, error) {
|
||||
resp := &LoadBalancerServiceLinkCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_SERVICE_LINK_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerServiceLinkClient) ById(id string) (*LoadBalancerServiceLink, error) {
|
||||
resp := &LoadBalancerServiceLink{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_SERVICE_LINK_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerServiceLinkClient) Delete(container *LoadBalancerServiceLink) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_SERVICE_LINK_TYPE, &container.Resource)
|
||||
}
|
||||
-132
@@ -1,132 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
LOAD_BALANCER_TARGET_TYPE = "loadBalancerTarget"
|
||||
)
|
||||
|
||||
type LoadBalancerTarget 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"`
|
||||
|
||||
InstanceId string `json:"instanceId,omitempty" yaml:"instance_id,omitempty"`
|
||||
|
||||
IpAddress string `json:"ipAddress,omitempty" yaml:"ip_address,omitempty"`
|
||||
|
||||
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
|
||||
|
||||
LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Ports []string `json:"ports,omitempty" yaml:"ports,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 LoadBalancerTargetCollection struct {
|
||||
Collection
|
||||
Data []LoadBalancerTarget `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalancerTargetClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type LoadBalancerTargetOperations interface {
|
||||
List(opts *ListOpts) (*LoadBalancerTargetCollection, error)
|
||||
Create(opts *LoadBalancerTarget) (*LoadBalancerTarget, error)
|
||||
Update(existing *LoadBalancerTarget, updates interface{}) (*LoadBalancerTarget, error)
|
||||
ById(id string) (*LoadBalancerTarget, error)
|
||||
Delete(container *LoadBalancerTarget) error
|
||||
|
||||
ActionCreate(*LoadBalancerTarget) (*LoadBalancerTarget, error)
|
||||
|
||||
ActionRemove(*LoadBalancerTarget) (*LoadBalancerTarget, error)
|
||||
|
||||
ActionUpdate(*LoadBalancerTarget) (*LoadBalancerTarget, error)
|
||||
}
|
||||
|
||||
func newLoadBalancerTargetClient(rancherClient *RancherClient) *LoadBalancerTargetClient {
|
||||
return &LoadBalancerTargetClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) Create(container *LoadBalancerTarget) (*LoadBalancerTarget, error) {
|
||||
resp := &LoadBalancerTarget{}
|
||||
err := c.rancherClient.doCreate(LOAD_BALANCER_TARGET_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) Update(existing *LoadBalancerTarget, updates interface{}) (*LoadBalancerTarget, error) {
|
||||
resp := &LoadBalancerTarget{}
|
||||
err := c.rancherClient.doUpdate(LOAD_BALANCER_TARGET_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) List(opts *ListOpts) (*LoadBalancerTargetCollection, error) {
|
||||
resp := &LoadBalancerTargetCollection{}
|
||||
err := c.rancherClient.doList(LOAD_BALANCER_TARGET_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) ById(id string) (*LoadBalancerTarget, error) {
|
||||
resp := &LoadBalancerTarget{}
|
||||
err := c.rancherClient.doById(LOAD_BALANCER_TARGET_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) Delete(container *LoadBalancerTarget) error {
|
||||
return c.rancherClient.doResourceDelete(LOAD_BALANCER_TARGET_TYPE, &container.Resource)
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) ActionCreate(resource *LoadBalancerTarget) (*LoadBalancerTarget, error) {
|
||||
|
||||
resp := &LoadBalancerTarget{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TARGET_TYPE, "create", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) ActionRemove(resource *LoadBalancerTarget) (*LoadBalancerTarget, error) {
|
||||
|
||||
resp := &LoadBalancerTarget{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TARGET_TYPE, "remove", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *LoadBalancerTargetClient) ActionUpdate(resource *LoadBalancerTarget) (*LoadBalancerTarget, error) {
|
||||
|
||||
resp := &LoadBalancerTarget{}
|
||||
|
||||
err := c.rancherClient.doAction(LOAD_BALANCER_TARGET_TYPE, "update", &resource.Resource, nil, resp)
|
||||
|
||||
return resp, err
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
MACHINE_DRIVER_ERROR_INPUT_TYPE = "machineDriverErrorInput"
|
||||
)
|
||||
|
||||
type MachineDriverErrorInput struct {
|
||||
Resource
|
||||
|
||||
ErrorMessage string `json:"errorMessage,omitempty" yaml:"error_message,omitempty"`
|
||||
}
|
||||
|
||||
type MachineDriverErrorInputCollection struct {
|
||||
Collection
|
||||
Data []MachineDriverErrorInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type MachineDriverErrorInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type MachineDriverErrorInputOperations interface {
|
||||
List(opts *ListOpts) (*MachineDriverErrorInputCollection, error)
|
||||
Create(opts *MachineDriverErrorInput) (*MachineDriverErrorInput, error)
|
||||
Update(existing *MachineDriverErrorInput, updates interface{}) (*MachineDriverErrorInput, error)
|
||||
ById(id string) (*MachineDriverErrorInput, error)
|
||||
Delete(container *MachineDriverErrorInput) error
|
||||
}
|
||||
|
||||
func newMachineDriverErrorInputClient(rancherClient *RancherClient) *MachineDriverErrorInputClient {
|
||||
return &MachineDriverErrorInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *MachineDriverErrorInputClient) Create(container *MachineDriverErrorInput) (*MachineDriverErrorInput, error) {
|
||||
resp := &MachineDriverErrorInput{}
|
||||
err := c.rancherClient.doCreate(MACHINE_DRIVER_ERROR_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverErrorInputClient) Update(existing *MachineDriverErrorInput, updates interface{}) (*MachineDriverErrorInput, error) {
|
||||
resp := &MachineDriverErrorInput{}
|
||||
err := c.rancherClient.doUpdate(MACHINE_DRIVER_ERROR_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverErrorInputClient) List(opts *ListOpts) (*MachineDriverErrorInputCollection, error) {
|
||||
resp := &MachineDriverErrorInputCollection{}
|
||||
err := c.rancherClient.doList(MACHINE_DRIVER_ERROR_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverErrorInputClient) ById(id string) (*MachineDriverErrorInput, error) {
|
||||
resp := &MachineDriverErrorInput{}
|
||||
err := c.rancherClient.doById(MACHINE_DRIVER_ERROR_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverErrorInputClient) Delete(container *MachineDriverErrorInput) error {
|
||||
return c.rancherClient.doResourceDelete(MACHINE_DRIVER_ERROR_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-71
@@ -1,71 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
MACHINE_DRIVER_UPDATE_INPUT_TYPE = "machineDriverUpdateInput"
|
||||
)
|
||||
|
||||
type MachineDriverUpdateInput struct {
|
||||
Resource
|
||||
|
||||
Md5checksum string `json:"md5checksum,omitempty" yaml:"md5checksum,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty" yaml:"name,omitempty"`
|
||||
|
||||
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
|
||||
}
|
||||
|
||||
type MachineDriverUpdateInputCollection struct {
|
||||
Collection
|
||||
Data []MachineDriverUpdateInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type MachineDriverUpdateInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type MachineDriverUpdateInputOperations interface {
|
||||
List(opts *ListOpts) (*MachineDriverUpdateInputCollection, error)
|
||||
Create(opts *MachineDriverUpdateInput) (*MachineDriverUpdateInput, error)
|
||||
Update(existing *MachineDriverUpdateInput, updates interface{}) (*MachineDriverUpdateInput, error)
|
||||
ById(id string) (*MachineDriverUpdateInput, error)
|
||||
Delete(container *MachineDriverUpdateInput) error
|
||||
}
|
||||
|
||||
func newMachineDriverUpdateInputClient(rancherClient *RancherClient) *MachineDriverUpdateInputClient {
|
||||
return &MachineDriverUpdateInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *MachineDriverUpdateInputClient) Create(container *MachineDriverUpdateInput) (*MachineDriverUpdateInput, error) {
|
||||
resp := &MachineDriverUpdateInput{}
|
||||
err := c.rancherClient.doCreate(MACHINE_DRIVER_UPDATE_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverUpdateInputClient) Update(existing *MachineDriverUpdateInput, updates interface{}) (*MachineDriverUpdateInput, error) {
|
||||
resp := &MachineDriverUpdateInput{}
|
||||
err := c.rancherClient.doUpdate(MACHINE_DRIVER_UPDATE_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverUpdateInputClient) List(opts *ListOpts) (*MachineDriverUpdateInputCollection, error) {
|
||||
resp := &MachineDriverUpdateInputCollection{}
|
||||
err := c.rancherClient.doList(MACHINE_DRIVER_UPDATE_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverUpdateInputClient) ById(id string) (*MachineDriverUpdateInput, error) {
|
||||
resp := &MachineDriverUpdateInput{}
|
||||
err := c.rancherClient.doById(MACHINE_DRIVER_UPDATE_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *MachineDriverUpdateInputClient) Delete(container *MachineDriverUpdateInput) error {
|
||||
return c.rancherClient.doResourceDelete(MACHINE_DRIVER_UPDATE_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-107
@@ -1,107 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
OPENSTACK_CONFIG_TYPE = "openstackConfig"
|
||||
)
|
||||
|
||||
type OpenstackConfig struct {
|
||||
Resource
|
||||
|
||||
AuthUrl string `json:"authUrl,omitempty" yaml:"auth_url,omitempty"`
|
||||
|
||||
AvailabilityZone string `json:"availabilityZone,omitempty" yaml:"availability_zone,omitempty"`
|
||||
|
||||
DomainId string `json:"domainId,omitempty" yaml:"domain_id,omitempty"`
|
||||
|
||||
DomainName string `json:"domainName,omitempty" yaml:"domain_name,omitempty"`
|
||||
|
||||
EndpointType string `json:"endpointType,omitempty" yaml:"endpoint_type,omitempty"`
|
||||
|
||||
FlavorId string `json:"flavorId,omitempty" yaml:"flavor_id,omitempty"`
|
||||
|
||||
FlavorName string `json:"flavorName,omitempty" yaml:"flavor_name,omitempty"`
|
||||
|
||||
FloatingipPool string `json:"floatingipPool,omitempty" yaml:"floatingip_pool,omitempty"`
|
||||
|
||||
ImageId string `json:"imageId,omitempty" yaml:"image_id,omitempty"`
|
||||
|
||||
ImageName string `json:"imageName,omitempty" yaml:"image_name,omitempty"`
|
||||
|
||||
Insecure bool `json:"insecure,omitempty" yaml:"insecure,omitempty"`
|
||||
|
||||
NetId string `json:"netId,omitempty" yaml:"net_id,omitempty"`
|
||||
|
||||
NetName string `json:"netName,omitempty" yaml:"net_name,omitempty"`
|
||||
|
||||
Password string `json:"password,omitempty" yaml:"password,omitempty"`
|
||||
|
||||
Region string `json:"region,omitempty" yaml:"region,omitempty"`
|
||||
|
||||
SecGroups string `json:"secGroups,omitempty" yaml:"sec_groups,omitempty"`
|
||||
|
||||
SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"`
|
||||
|
||||
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
|
||||
|
||||
TenantId string `json:"tenantId,omitempty" yaml:"tenant_id,omitempty"`
|
||||
|
||||
TenantName string `json:"tenantName,omitempty" yaml:"tenant_name,omitempty"`
|
||||
|
||||
Username string `json:"username,omitempty" yaml:"username,omitempty"`
|
||||
}
|
||||
|
||||
type OpenstackConfigCollection struct {
|
||||
Collection
|
||||
Data []OpenstackConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type OpenstackConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type OpenstackConfigOperations interface {
|
||||
List(opts *ListOpts) (*OpenstackConfigCollection, error)
|
||||
Create(opts *OpenstackConfig) (*OpenstackConfig, error)
|
||||
Update(existing *OpenstackConfig, updates interface{}) (*OpenstackConfig, error)
|
||||
ById(id string) (*OpenstackConfig, error)
|
||||
Delete(container *OpenstackConfig) error
|
||||
}
|
||||
|
||||
func newOpenstackConfigClient(rancherClient *RancherClient) *OpenstackConfigClient {
|
||||
return &OpenstackConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *OpenstackConfigClient) Create(container *OpenstackConfig) (*OpenstackConfig, error) {
|
||||
resp := &OpenstackConfig{}
|
||||
err := c.rancherClient.doCreate(OPENSTACK_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *OpenstackConfigClient) Update(existing *OpenstackConfig, updates interface{}) (*OpenstackConfig, error) {
|
||||
resp := &OpenstackConfig{}
|
||||
err := c.rancherClient.doUpdate(OPENSTACK_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *OpenstackConfigClient) List(opts *ListOpts) (*OpenstackConfigCollection, error) {
|
||||
resp := &OpenstackConfigCollection{}
|
||||
err := c.rancherClient.doList(OPENSTACK_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *OpenstackConfigClient) ById(id string) (*OpenstackConfig, error) {
|
||||
resp := &OpenstackConfig{}
|
||||
err := c.rancherClient.doById(OPENSTACK_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *OpenstackConfigClient) Delete(container *OpenstackConfig) error {
|
||||
return c.rancherClient.doResourceDelete(OPENSTACK_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
RACKSPACE_CONFIG_TYPE = "rackspaceConfig"
|
||||
)
|
||||
|
||||
type RackspaceConfig struct {
|
||||
Resource
|
||||
|
||||
ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"`
|
||||
|
||||
DockerInstall string `json:"dockerInstall,omitempty" yaml:"docker_install,omitempty"`
|
||||
|
||||
EndpointType string `json:"endpointType,omitempty" yaml:"endpoint_type,omitempty"`
|
||||
|
||||
FlavorId string `json:"flavorId,omitempty" yaml:"flavor_id,omitempty"`
|
||||
|
||||
ImageId string `json:"imageId,omitempty" yaml:"image_id,omitempty"`
|
||||
|
||||
Region string `json:"region,omitempty" yaml:"region,omitempty"`
|
||||
|
||||
SshPort string `json:"sshPort,omitempty" yaml:"ssh_port,omitempty"`
|
||||
|
||||
SshUser string `json:"sshUser,omitempty" yaml:"ssh_user,omitempty"`
|
||||
|
||||
Username string `json:"username,omitempty" yaml:"username,omitempty"`
|
||||
}
|
||||
|
||||
type RackspaceConfigCollection struct {
|
||||
Collection
|
||||
Data []RackspaceConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type RackspaceConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type RackspaceConfigOperations interface {
|
||||
List(opts *ListOpts) (*RackspaceConfigCollection, error)
|
||||
Create(opts *RackspaceConfig) (*RackspaceConfig, error)
|
||||
Update(existing *RackspaceConfig, updates interface{}) (*RackspaceConfig, error)
|
||||
ById(id string) (*RackspaceConfig, error)
|
||||
Delete(container *RackspaceConfig) error
|
||||
}
|
||||
|
||||
func newRackspaceConfigClient(rancherClient *RancherClient) *RackspaceConfigClient {
|
||||
return &RackspaceConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *RackspaceConfigClient) Create(container *RackspaceConfig) (*RackspaceConfig, error) {
|
||||
resp := &RackspaceConfig{}
|
||||
err := c.rancherClient.doCreate(RACKSPACE_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RackspaceConfigClient) Update(existing *RackspaceConfig, updates interface{}) (*RackspaceConfig, error) {
|
||||
resp := &RackspaceConfig{}
|
||||
err := c.rancherClient.doUpdate(RACKSPACE_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RackspaceConfigClient) List(opts *ListOpts) (*RackspaceConfigCollection, error) {
|
||||
resp := &RackspaceConfigCollection{}
|
||||
err := c.rancherClient.doList(RACKSPACE_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RackspaceConfigClient) ById(id string) (*RackspaceConfig, error) {
|
||||
resp := &RackspaceConfig{}
|
||||
err := c.rancherClient.doById(RACKSPACE_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RackspaceConfigClient) Delete(container *RackspaceConfig) error {
|
||||
return c.rancherClient.doResourceDelete(RACKSPACE_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
REMOVE_LABEL_INPUT_TYPE = "removeLabelInput"
|
||||
)
|
||||
|
||||
type RemoveLabelInput struct {
|
||||
Resource
|
||||
|
||||
Label string `json:"label,omitempty"`
|
||||
}
|
||||
|
||||
type RemoveLabelInputCollection struct {
|
||||
Collection
|
||||
Data []RemoveLabelInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type RemoveLabelInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type RemoveLabelInputOperations interface {
|
||||
List(opts *ListOpts) (*RemoveLabelInputCollection, error)
|
||||
Create(opts *RemoveLabelInput) (*RemoveLabelInput, error)
|
||||
Update(existing *RemoveLabelInput, updates interface{}) (*RemoveLabelInput, error)
|
||||
ById(id string) (*RemoveLabelInput, error)
|
||||
Delete(container *RemoveLabelInput) error
|
||||
}
|
||||
|
||||
func newRemoveLabelInputClient(rancherClient *RancherClient) *RemoveLabelInputClient {
|
||||
return &RemoveLabelInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *RemoveLabelInputClient) Create(container *RemoveLabelInput) (*RemoveLabelInput, error) {
|
||||
resp := &RemoveLabelInput{}
|
||||
err := c.rancherClient.doCreate(REMOVE_LABEL_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLabelInputClient) Update(existing *RemoveLabelInput, updates interface{}) (*RemoveLabelInput, error) {
|
||||
resp := &RemoveLabelInput{}
|
||||
err := c.rancherClient.doUpdate(REMOVE_LABEL_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLabelInputClient) List(opts *ListOpts) (*RemoveLabelInputCollection, error) {
|
||||
resp := &RemoveLabelInputCollection{}
|
||||
err := c.rancherClient.doList(REMOVE_LABEL_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLabelInputClient) ById(id string) (*RemoveLabelInput, error) {
|
||||
resp := &RemoveLabelInput{}
|
||||
err := c.rancherClient.doById(REMOVE_LABEL_INPUT_TYPE, id, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLabelInputClient) Delete(container *RemoveLabelInput) error {
|
||||
return c.rancherClient.doResourceDelete(REMOVE_LABEL_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
REMOVE_LOAD_BALANCER_INPUT_TYPE = "removeLoadBalancerInput"
|
||||
)
|
||||
|
||||
type RemoveLoadBalancerInput struct {
|
||||
Resource
|
||||
|
||||
LoadBalancerId string `json:"loadBalancerId,omitempty" yaml:"load_balancer_id,omitempty"`
|
||||
}
|
||||
|
||||
type RemoveLoadBalancerInputCollection struct {
|
||||
Collection
|
||||
Data []RemoveLoadBalancerInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type RemoveLoadBalancerInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type RemoveLoadBalancerInputOperations interface {
|
||||
List(opts *ListOpts) (*RemoveLoadBalancerInputCollection, error)
|
||||
Create(opts *RemoveLoadBalancerInput) (*RemoveLoadBalancerInput, error)
|
||||
Update(existing *RemoveLoadBalancerInput, updates interface{}) (*RemoveLoadBalancerInput, error)
|
||||
ById(id string) (*RemoveLoadBalancerInput, error)
|
||||
Delete(container *RemoveLoadBalancerInput) error
|
||||
}
|
||||
|
||||
func newRemoveLoadBalancerInputClient(rancherClient *RancherClient) *RemoveLoadBalancerInputClient {
|
||||
return &RemoveLoadBalancerInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *RemoveLoadBalancerInputClient) Create(container *RemoveLoadBalancerInput) (*RemoveLoadBalancerInput, error) {
|
||||
resp := &RemoveLoadBalancerInput{}
|
||||
err := c.rancherClient.doCreate(REMOVE_LOAD_BALANCER_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLoadBalancerInputClient) Update(existing *RemoveLoadBalancerInput, updates interface{}) (*RemoveLoadBalancerInput, error) {
|
||||
resp := &RemoveLoadBalancerInput{}
|
||||
err := c.rancherClient.doUpdate(REMOVE_LOAD_BALANCER_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLoadBalancerInputClient) List(opts *ListOpts) (*RemoveLoadBalancerInputCollection, error) {
|
||||
resp := &RemoveLoadBalancerInputCollection{}
|
||||
err := c.rancherClient.doList(REMOVE_LOAD_BALANCER_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLoadBalancerInputClient) ById(id string) (*RemoveLoadBalancerInput, error) {
|
||||
resp := &RemoveLoadBalancerInput{}
|
||||
err := c.rancherClient.doById(REMOVE_LOAD_BALANCER_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *RemoveLoadBalancerInputClient) Delete(container *RemoveLoadBalancerInput) error {
|
||||
return c.rancherClient.doResourceDelete(REMOVE_LOAD_BALANCER_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
SET_LABELS_INPUT_TYPE = "setLabelsInput"
|
||||
)
|
||||
|
||||
type SetLabelsInput struct {
|
||||
Resource
|
||||
|
||||
Labels interface{} `json:"labels,omitempty" yaml:"labels,omitempty"`
|
||||
}
|
||||
|
||||
type SetLabelsInputCollection struct {
|
||||
Collection
|
||||
Data []SetLabelsInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type SetLabelsInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type SetLabelsInputOperations interface {
|
||||
List(opts *ListOpts) (*SetLabelsInputCollection, error)
|
||||
Create(opts *SetLabelsInput) (*SetLabelsInput, error)
|
||||
Update(existing *SetLabelsInput, updates interface{}) (*SetLabelsInput, error)
|
||||
ById(id string) (*SetLabelsInput, error)
|
||||
Delete(container *SetLabelsInput) error
|
||||
}
|
||||
|
||||
func newSetLabelsInputClient(rancherClient *RancherClient) *SetLabelsInputClient {
|
||||
return &SetLabelsInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SetLabelsInputClient) Create(container *SetLabelsInput) (*SetLabelsInput, error) {
|
||||
resp := &SetLabelsInput{}
|
||||
err := c.rancherClient.doCreate(SET_LABELS_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLabelsInputClient) Update(existing *SetLabelsInput, updates interface{}) (*SetLabelsInput, error) {
|
||||
resp := &SetLabelsInput{}
|
||||
err := c.rancherClient.doUpdate(SET_LABELS_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLabelsInputClient) List(opts *ListOpts) (*SetLabelsInputCollection, error) {
|
||||
resp := &SetLabelsInputCollection{}
|
||||
err := c.rancherClient.doList(SET_LABELS_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLabelsInputClient) ById(id string) (*SetLabelsInput, error) {
|
||||
resp := &SetLabelsInput{}
|
||||
err := c.rancherClient.doById(SET_LABELS_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLabelsInputClient) Delete(container *SetLabelsInput) error {
|
||||
return c.rancherClient.doResourceDelete(SET_LABELS_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
SET_LOAD_BALANCER_HOSTS_INPUT_TYPE = "setLoadBalancerHostsInput"
|
||||
)
|
||||
|
||||
type SetLoadBalancerHostsInput struct {
|
||||
Resource
|
||||
|
||||
HostIds []string `json:"hostIds,omitempty" yaml:"host_ids,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerHostsInputCollection struct {
|
||||
Collection
|
||||
Data []SetLoadBalancerHostsInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerHostsInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type SetLoadBalancerHostsInputOperations interface {
|
||||
List(opts *ListOpts) (*SetLoadBalancerHostsInputCollection, error)
|
||||
Create(opts *SetLoadBalancerHostsInput) (*SetLoadBalancerHostsInput, error)
|
||||
Update(existing *SetLoadBalancerHostsInput, updates interface{}) (*SetLoadBalancerHostsInput, error)
|
||||
ById(id string) (*SetLoadBalancerHostsInput, error)
|
||||
Delete(container *SetLoadBalancerHostsInput) error
|
||||
}
|
||||
|
||||
func newSetLoadBalancerHostsInputClient(rancherClient *RancherClient) *SetLoadBalancerHostsInputClient {
|
||||
return &SetLoadBalancerHostsInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerHostsInputClient) Create(container *SetLoadBalancerHostsInput) (*SetLoadBalancerHostsInput, error) {
|
||||
resp := &SetLoadBalancerHostsInput{}
|
||||
err := c.rancherClient.doCreate(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerHostsInputClient) Update(existing *SetLoadBalancerHostsInput, updates interface{}) (*SetLoadBalancerHostsInput, error) {
|
||||
resp := &SetLoadBalancerHostsInput{}
|
||||
err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerHostsInputClient) List(opts *ListOpts) (*SetLoadBalancerHostsInputCollection, error) {
|
||||
resp := &SetLoadBalancerHostsInputCollection{}
|
||||
err := c.rancherClient.doList(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerHostsInputClient) ById(id string) (*SetLoadBalancerHostsInput, error) {
|
||||
resp := &SetLoadBalancerHostsInput{}
|
||||
err := c.rancherClient.doById(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerHostsInputClient) Delete(container *SetLoadBalancerHostsInput) error {
|
||||
return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_HOSTS_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE = "setLoadBalancerListenersInput"
|
||||
)
|
||||
|
||||
type SetLoadBalancerListenersInput struct {
|
||||
Resource
|
||||
|
||||
LoadBalancerListenerIds []string `json:"loadBalancerListenerIds,omitempty" yaml:"load_balancer_listener_ids,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerListenersInputCollection struct {
|
||||
Collection
|
||||
Data []SetLoadBalancerListenersInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerListenersInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type SetLoadBalancerListenersInputOperations interface {
|
||||
List(opts *ListOpts) (*SetLoadBalancerListenersInputCollection, error)
|
||||
Create(opts *SetLoadBalancerListenersInput) (*SetLoadBalancerListenersInput, error)
|
||||
Update(existing *SetLoadBalancerListenersInput, updates interface{}) (*SetLoadBalancerListenersInput, error)
|
||||
ById(id string) (*SetLoadBalancerListenersInput, error)
|
||||
Delete(container *SetLoadBalancerListenersInput) error
|
||||
}
|
||||
|
||||
func newSetLoadBalancerListenersInputClient(rancherClient *RancherClient) *SetLoadBalancerListenersInputClient {
|
||||
return &SetLoadBalancerListenersInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerListenersInputClient) Create(container *SetLoadBalancerListenersInput) (*SetLoadBalancerListenersInput, error) {
|
||||
resp := &SetLoadBalancerListenersInput{}
|
||||
err := c.rancherClient.doCreate(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerListenersInputClient) Update(existing *SetLoadBalancerListenersInput, updates interface{}) (*SetLoadBalancerListenersInput, error) {
|
||||
resp := &SetLoadBalancerListenersInput{}
|
||||
err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerListenersInputClient) List(opts *ListOpts) (*SetLoadBalancerListenersInputCollection, error) {
|
||||
resp := &SetLoadBalancerListenersInputCollection{}
|
||||
err := c.rancherClient.doList(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerListenersInputClient) ById(id string) (*SetLoadBalancerListenersInput, error) {
|
||||
resp := &SetLoadBalancerListenersInput{}
|
||||
err := c.rancherClient.doById(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerListenersInputClient) Delete(container *SetLoadBalancerListenersInput) error {
|
||||
return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_LISTENERS_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE = "setLoadBalancerServiceLinksInput"
|
||||
)
|
||||
|
||||
type SetLoadBalancerServiceLinksInput struct {
|
||||
Resource
|
||||
|
||||
ServiceLinks []interface{} `json:"serviceLinks,omitempty" yaml:"service_links,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerServiceLinksInputCollection struct {
|
||||
Collection
|
||||
Data []SetLoadBalancerServiceLinksInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerServiceLinksInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type SetLoadBalancerServiceLinksInputOperations interface {
|
||||
List(opts *ListOpts) (*SetLoadBalancerServiceLinksInputCollection, error)
|
||||
Create(opts *SetLoadBalancerServiceLinksInput) (*SetLoadBalancerServiceLinksInput, error)
|
||||
Update(existing *SetLoadBalancerServiceLinksInput, updates interface{}) (*SetLoadBalancerServiceLinksInput, error)
|
||||
ById(id string) (*SetLoadBalancerServiceLinksInput, error)
|
||||
Delete(container *SetLoadBalancerServiceLinksInput) error
|
||||
}
|
||||
|
||||
func newSetLoadBalancerServiceLinksInputClient(rancherClient *RancherClient) *SetLoadBalancerServiceLinksInputClient {
|
||||
return &SetLoadBalancerServiceLinksInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerServiceLinksInputClient) Create(container *SetLoadBalancerServiceLinksInput) (*SetLoadBalancerServiceLinksInput, error) {
|
||||
resp := &SetLoadBalancerServiceLinksInput{}
|
||||
err := c.rancherClient.doCreate(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerServiceLinksInputClient) Update(existing *SetLoadBalancerServiceLinksInput, updates interface{}) (*SetLoadBalancerServiceLinksInput, error) {
|
||||
resp := &SetLoadBalancerServiceLinksInput{}
|
||||
err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerServiceLinksInputClient) List(opts *ListOpts) (*SetLoadBalancerServiceLinksInputCollection, error) {
|
||||
resp := &SetLoadBalancerServiceLinksInputCollection{}
|
||||
err := c.rancherClient.doList(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerServiceLinksInputClient) ById(id string) (*SetLoadBalancerServiceLinksInput, error) {
|
||||
resp := &SetLoadBalancerServiceLinksInput{}
|
||||
err := c.rancherClient.doById(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerServiceLinksInputClient) Delete(container *SetLoadBalancerServiceLinksInput) error {
|
||||
return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_SERVICE_LINKS_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
Generated
Vendored
-67
@@ -1,67 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
SET_LOAD_BALANCER_TARGETS_INPUT_TYPE = "setLoadBalancerTargetsInput"
|
||||
)
|
||||
|
||||
type SetLoadBalancerTargetsInput struct {
|
||||
Resource
|
||||
|
||||
LoadBalancerTargets []interface{} `json:"loadBalancerTargets,omitempty" yaml:"load_balancer_targets,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerTargetsInputCollection struct {
|
||||
Collection
|
||||
Data []SetLoadBalancerTargetsInput `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type SetLoadBalancerTargetsInputClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type SetLoadBalancerTargetsInputOperations interface {
|
||||
List(opts *ListOpts) (*SetLoadBalancerTargetsInputCollection, error)
|
||||
Create(opts *SetLoadBalancerTargetsInput) (*SetLoadBalancerTargetsInput, error)
|
||||
Update(existing *SetLoadBalancerTargetsInput, updates interface{}) (*SetLoadBalancerTargetsInput, error)
|
||||
ById(id string) (*SetLoadBalancerTargetsInput, error)
|
||||
Delete(container *SetLoadBalancerTargetsInput) error
|
||||
}
|
||||
|
||||
func newSetLoadBalancerTargetsInputClient(rancherClient *RancherClient) *SetLoadBalancerTargetsInputClient {
|
||||
return &SetLoadBalancerTargetsInputClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerTargetsInputClient) Create(container *SetLoadBalancerTargetsInput) (*SetLoadBalancerTargetsInput, error) {
|
||||
resp := &SetLoadBalancerTargetsInput{}
|
||||
err := c.rancherClient.doCreate(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerTargetsInputClient) Update(existing *SetLoadBalancerTargetsInput, updates interface{}) (*SetLoadBalancerTargetsInput, error) {
|
||||
resp := &SetLoadBalancerTargetsInput{}
|
||||
err := c.rancherClient.doUpdate(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerTargetsInputClient) List(opts *ListOpts) (*SetLoadBalancerTargetsInputCollection, error) {
|
||||
resp := &SetLoadBalancerTargetsInputCollection{}
|
||||
err := c.rancherClient.doList(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerTargetsInputClient) ById(id string) (*SetLoadBalancerTargetsInput, error) {
|
||||
resp := &SetLoadBalancerTargetsInput{}
|
||||
err := c.rancherClient.doById(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SetLoadBalancerTargetsInputClient) Delete(container *SetLoadBalancerTargetsInput) error {
|
||||
return c.rancherClient.doResourceDelete(SET_LOAD_BALANCER_TARGETS_INPUT_TYPE, &container.Resource)
|
||||
}
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
SOFTLAYER_CONFIG_TYPE = "softlayerConfig"
|
||||
)
|
||||
|
||||
type SoftlayerConfig struct {
|
||||
Resource
|
||||
|
||||
ApiEndpoint string `json:"apiEndpoint,omitempty" yaml:"api_endpoint,omitempty"`
|
||||
|
||||
ApiKey string `json:"apiKey,omitempty" yaml:"api_key,omitempty"`
|
||||
|
||||
Cpu string `json:"cpu,omitempty" yaml:"cpu,omitempty"`
|
||||
|
||||
DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"`
|
||||
|
||||
Domain string `json:"domain,omitempty" yaml:"domain,omitempty"`
|
||||
|
||||
Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty"`
|
||||
|
||||
HourlyBilling bool `json:"hourlyBilling,omitempty" yaml:"hourly_billing,omitempty"`
|
||||
|
||||
Image string `json:"image,omitempty" yaml:"image,omitempty"`
|
||||
|
||||
LocalDisk bool `json:"localDisk,omitempty" yaml:"local_disk,omitempty"`
|
||||
|
||||
Memory string `json:"memory,omitempty" yaml:"memory,omitempty"`
|
||||
|
||||
PrivateNetOnly bool `json:"privateNetOnly,omitempty" yaml:"private_net_only,omitempty"`
|
||||
|
||||
PrivateVlanId string `json:"privateVlanId,omitempty" yaml:"private_vlan_id,omitempty"`
|
||||
|
||||
PublicVlanId string `json:"publicVlanId,omitempty" yaml:"public_vlan_id,omitempty"`
|
||||
|
||||
Region string `json:"region,omitempty" yaml:"region,omitempty"`
|
||||
|
||||
User string `json:"user,omitempty" yaml:"user,omitempty"`
|
||||
}
|
||||
|
||||
type SoftlayerConfigCollection struct {
|
||||
Collection
|
||||
Data []SoftlayerConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type SoftlayerConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type SoftlayerConfigOperations interface {
|
||||
List(opts *ListOpts) (*SoftlayerConfigCollection, error)
|
||||
Create(opts *SoftlayerConfig) (*SoftlayerConfig, error)
|
||||
Update(existing *SoftlayerConfig, updates interface{}) (*SoftlayerConfig, error)
|
||||
ById(id string) (*SoftlayerConfig, error)
|
||||
Delete(container *SoftlayerConfig) error
|
||||
}
|
||||
|
||||
func newSoftlayerConfigClient(rancherClient *RancherClient) *SoftlayerConfigClient {
|
||||
return &SoftlayerConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SoftlayerConfigClient) Create(container *SoftlayerConfig) (*SoftlayerConfig, error) {
|
||||
resp := &SoftlayerConfig{}
|
||||
err := c.rancherClient.doCreate(SOFTLAYER_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SoftlayerConfigClient) Update(existing *SoftlayerConfig, updates interface{}) (*SoftlayerConfig, error) {
|
||||
resp := &SoftlayerConfig{}
|
||||
err := c.rancherClient.doUpdate(SOFTLAYER_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SoftlayerConfigClient) List(opts *ListOpts) (*SoftlayerConfigCollection, error) {
|
||||
resp := &SoftlayerConfigCollection{}
|
||||
err := c.rancherClient.doList(SOFTLAYER_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SoftlayerConfigClient) ById(id string) (*SoftlayerConfig, error) {
|
||||
resp := &SoftlayerConfig{}
|
||||
err := c.rancherClient.doById(SOFTLAYER_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SoftlayerConfigClient) Delete(container *SoftlayerConfig) error {
|
||||
return c.rancherClient.doResourceDelete(SOFTLAYER_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
SUBSCRIBE_TYPE = "subscribe"
|
||||
)
|
||||
|
||||
type Subscribe struct {
|
||||
Resource
|
||||
|
||||
AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"`
|
||||
|
||||
EventNames []string `json:"eventNames,omitempty" yaml:"event_names,omitempty"`
|
||||
}
|
||||
|
||||
type SubscribeCollection struct {
|
||||
Collection
|
||||
Data []Subscribe `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type SubscribeClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type SubscribeOperations interface {
|
||||
List(opts *ListOpts) (*SubscribeCollection, error)
|
||||
Create(opts *Subscribe) (*Subscribe, error)
|
||||
Update(existing *Subscribe, updates interface{}) (*Subscribe, error)
|
||||
ById(id string) (*Subscribe, error)
|
||||
Delete(container *Subscribe) error
|
||||
}
|
||||
|
||||
func newSubscribeClient(rancherClient *RancherClient) *SubscribeClient {
|
||||
return &SubscribeClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SubscribeClient) Create(container *Subscribe) (*Subscribe, error) {
|
||||
resp := &Subscribe{}
|
||||
err := c.rancherClient.doCreate(SUBSCRIBE_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SubscribeClient) Update(existing *Subscribe, updates interface{}) (*Subscribe, error) {
|
||||
resp := &Subscribe{}
|
||||
err := c.rancherClient.doUpdate(SUBSCRIBE_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SubscribeClient) List(opts *ListOpts) (*SubscribeCollection, error) {
|
||||
resp := &SubscribeCollection{}
|
||||
err := c.rancherClient.doList(SUBSCRIBE_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SubscribeClient) ById(id string) (*Subscribe, error) {
|
||||
resp := &Subscribe{}
|
||||
err := c.rancherClient.doById(SUBSCRIBE_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *SubscribeClient) Delete(container *Subscribe) error {
|
||||
return c.rancherClient.doResourceDelete(SUBSCRIBE_TYPE, &container.Resource)
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
UBIQUITY_CONFIG_TYPE = "ubiquityConfig"
|
||||
)
|
||||
|
||||
type UbiquityConfig struct {
|
||||
Resource
|
||||
|
||||
ApiToken string `json:"apiToken,omitempty" yaml:"api_token,omitempty"`
|
||||
|
||||
ApiUsername string `json:"apiUsername,omitempty" yaml:"api_username,omitempty"`
|
||||
|
||||
ClientId string `json:"clientId,omitempty" yaml:"client_id,omitempty"`
|
||||
|
||||
FlavorId string `json:"flavorId,omitempty" yaml:"flavor_id,omitempty"`
|
||||
|
||||
ImageId string `json:"imageId,omitempty" yaml:"image_id,omitempty"`
|
||||
|
||||
ZoneId string `json:"zoneId,omitempty" yaml:"zone_id,omitempty"`
|
||||
}
|
||||
|
||||
type UbiquityConfigCollection struct {
|
||||
Collection
|
||||
Data []UbiquityConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type UbiquityConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type UbiquityConfigOperations interface {
|
||||
List(opts *ListOpts) (*UbiquityConfigCollection, error)
|
||||
Create(opts *UbiquityConfig) (*UbiquityConfig, error)
|
||||
Update(existing *UbiquityConfig, updates interface{}) (*UbiquityConfig, error)
|
||||
ById(id string) (*UbiquityConfig, error)
|
||||
Delete(container *UbiquityConfig) error
|
||||
}
|
||||
|
||||
func newUbiquityConfigClient(rancherClient *RancherClient) *UbiquityConfigClient {
|
||||
return &UbiquityConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *UbiquityConfigClient) Create(container *UbiquityConfig) (*UbiquityConfig, error) {
|
||||
resp := &UbiquityConfig{}
|
||||
err := c.rancherClient.doCreate(UBIQUITY_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *UbiquityConfigClient) Update(existing *UbiquityConfig, updates interface{}) (*UbiquityConfig, error) {
|
||||
resp := &UbiquityConfig{}
|
||||
err := c.rancherClient.doUpdate(UBIQUITY_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *UbiquityConfigClient) List(opts *ListOpts) (*UbiquityConfigCollection, error) {
|
||||
resp := &UbiquityConfigCollection{}
|
||||
err := c.rancherClient.doList(UBIQUITY_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *UbiquityConfigClient) ById(id string) (*UbiquityConfig, error) {
|
||||
resp := &UbiquityConfig{}
|
||||
err := c.rancherClient.doById(UBIQUITY_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *UbiquityConfigClient) Delete(container *UbiquityConfig) error {
|
||||
return c.rancherClient.doResourceDelete(UBIQUITY_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
package client
|
||||
|
||||
const (
|
||||
VIRTUALBOX_CONFIG_TYPE = "virtualboxConfig"
|
||||
)
|
||||
|
||||
type VirtualboxConfig struct {
|
||||
Resource
|
||||
|
||||
Boot2dockerUrl string `json:"boot2dockerUrl,omitempty" yaml:"boot2docker_url,omitempty"`
|
||||
|
||||
CpuCount string `json:"cpuCount,omitempty" yaml:"cpu_count,omitempty"`
|
||||
|
||||
DiskSize string `json:"diskSize,omitempty" yaml:"disk_size,omitempty"`
|
||||
|
||||
HostonlyCidr string `json:"hostonlyCidr,omitempty" yaml:"hostonly_cidr,omitempty"`
|
||||
|
||||
ImportBoot2dockerVm string `json:"importBoot2dockerVm,omitempty" yaml:"import_boot2docker_vm,omitempty"`
|
||||
|
||||
Memory string `json:"memory,omitempty" yaml:"memory,omitempty"`
|
||||
|
||||
NoShare bool `json:"noShare,omitempty" yaml:"no_share,omitempty"`
|
||||
}
|
||||
|
||||
type VirtualboxConfigCollection struct {
|
||||
Collection
|
||||
Data []VirtualboxConfig `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type VirtualboxConfigClient struct {
|
||||
rancherClient *RancherClient
|
||||
}
|
||||
|
||||
type VirtualboxConfigOperations interface {
|
||||
List(opts *ListOpts) (*VirtualboxConfigCollection, error)
|
||||
Create(opts *VirtualboxConfig) (*VirtualboxConfig, error)
|
||||
Update(existing *VirtualboxConfig, updates interface{}) (*VirtualboxConfig, error)
|
||||
ById(id string) (*VirtualboxConfig, error)
|
||||
Delete(container *VirtualboxConfig) error
|
||||
}
|
||||
|
||||
func newVirtualboxConfigClient(rancherClient *RancherClient) *VirtualboxConfigClient {
|
||||
return &VirtualboxConfigClient{
|
||||
rancherClient: rancherClient,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *VirtualboxConfigClient) Create(container *VirtualboxConfig) (*VirtualboxConfig, error) {
|
||||
resp := &VirtualboxConfig{}
|
||||
err := c.rancherClient.doCreate(VIRTUALBOX_CONFIG_TYPE, container, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *VirtualboxConfigClient) Update(existing *VirtualboxConfig, updates interface{}) (*VirtualboxConfig, error) {
|
||||
resp := &VirtualboxConfig{}
|
||||
err := c.rancherClient.doUpdate(VIRTUALBOX_CONFIG_TYPE, &existing.Resource, updates, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *VirtualboxConfigClient) List(opts *ListOpts) (*VirtualboxConfigCollection, error) {
|
||||
resp := &VirtualboxConfigCollection{}
|
||||
err := c.rancherClient.doList(VIRTUALBOX_CONFIG_TYPE, opts, resp)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *VirtualboxConfigClient) ById(id string) (*VirtualboxConfig, error) {
|
||||
resp := &VirtualboxConfig{}
|
||||
err := c.rancherClient.doById(VIRTUALBOX_CONFIG_TYPE, id, resp)
|
||||
if apiError, ok := err.(*ApiError); ok {
|
||||
if apiError.StatusCode == 404 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (c *VirtualboxConfigClient) Delete(container *VirtualboxConfig) error {
|
||||
return c.rancherClient.doResourceDelete(VIRTUALBOX_CONFIG_TYPE, &container.Resource)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user