├── .gitignore ├── Dockerfile ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Makefile ├── README.md ├── docs └── images │ ├── function.png │ ├── install.png │ ├── invoke.png │ └── mlb.png ├── faas-dcos.json ├── functions.yml ├── handlers ├── common.go ├── delete.go ├── deploy.go ├── health.go ├── proxy.go ├── reader.go └── replicas.go ├── prometheus ├── Dockerfile.alertmanager.dcos ├── Dockerfile.prometheus.dcos ├── Makefile ├── dcos.alert.rules ├── dcos.alertmanager.yml └── dcos.prometheus.yml ├── read_config.go ├── server.go └── vendor └── github.com ├── donovanhide └── eventsource │ ├── README.md │ ├── codec_test.go │ ├── decoder.go │ ├── decoder_test.go │ ├── encoder.go │ ├── example_error_handling_stream_test.go │ ├── example_event_test.go │ ├── example_repository_test.go │ ├── interface.go │ ├── normalise.go │ ├── normalise_test.go │ ├── repository.go │ ├── server.go │ ├── server_test.go │ ├── stream.go │ └── stream_test.go ├── gambol99 └── go-marathon │ ├── .gitignore │ ├── .travis.yml │ ├── AUTHORS │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── Makefile │ ├── README.md │ ├── application.go │ ├── application_test.go │ ├── client.go │ ├── client_test.go │ ├── cluster.go │ ├── cluster_test.go │ ├── config.go │ ├── const.go │ ├── deployment.go │ ├── deployment_test.go │ ├── docker.go │ ├── docker_test.go │ ├── error.go │ ├── error_test.go │ ├── events.go │ ├── examples │ ├── Makefile │ ├── applications │ │ └── main.go │ ├── docker-compose.yml │ ├── events_callback_transport │ │ └── main.go │ ├── events_sse_transport │ │ └── main.go │ ├── glog │ │ └── main.go │ ├── groups │ │ └── main.go │ ├── multiple_endpoints │ │ └── main.go │ ├── queue │ │ └── main.go │ └── tasks │ │ └── main.go │ ├── group.go │ ├── group_test.go │ ├── health.go │ ├── info.go │ ├── info_test.go │ ├── last_task_failure.go │ ├── port_definition.go │ ├── queue.go │ ├── queue_test.go │ ├── subscription.go │ ├── subscription_test.go │ ├── task.go │ ├── task_test.go │ ├── testing_utils_test.go │ ├── tests │ └── rest-api │ │ └── methods.yml │ ├── update_strategy.go │ ├── utils.go │ └── utils_test.go ├── google └── go-querystring │ ├── .gitignore │ ├── CONTRIBUTING.md │ ├── LICENSE │ ├── README.md │ └── query │ ├── encode.go │ └── encode_test.go ├── gorilla ├── context │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── context.go │ ├── context_test.go │ └── doc.go └── mux │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── bench_test.go │ ├── context_gorilla.go │ ├── context_gorilla_test.go │ ├── context_native.go │ ├── context_native_test.go │ ├── doc.go │ ├── mux.go │ ├── mux_test.go │ ├── old_test.go │ ├── regexp.go │ └── route.go ├── openfaas ├── faas-netes │ ├── .DEREK.yml │ ├── .github │ │ ├── ISSUE_TEMPLATE.md │ │ └── PULL_REQUEST_TEMPLATE.md │ ├── .gitignore │ ├── .travis.yml │ ├── CONTRIBUTING.md │ ├── Dockerfile │ ├── Dockerfile.arm64 │ ├── Dockerfile.armhf │ ├── Dockerfile.non-multi │ ├── HELM.md │ ├── LICENSE │ ├── MAINTAINERS │ ├── Makefile │ ├── QuickStart.md │ ├── README.md │ ├── SECRETS.md │ ├── build.sh │ ├── cloud │ │ └── lb.yml │ ├── contrib │ │ ├── busybox.yml │ │ └── set_travis_experimental_mode.sh │ ├── faas.arm64.yml │ ├── faas.armhf.yml │ ├── faas.async.armhf.yml │ ├── faas.async.yml │ ├── faas.yml │ ├── handlers │ │ ├── delete.go │ │ ├── deploy.go │ │ ├── proxy.go │ │ ├── reader.go │ │ ├── replicas.go │ │ └── update.go │ ├── monitoring-config.armhf.yml │ ├── monitoring.armhf.yml │ ├── monitoring.yml │ ├── nats.armhf.yml │ ├── nats.yml │ ├── openfaas │ │ ├── Chart.yaml │ │ ├── templates │ │ │ ├── _helpers.tpl │ │ │ ├── configmaps.yaml │ │ │ ├── external-service-access.yaml │ │ │ ├── faas.yaml │ │ │ ├── ingress.yaml │ │ │ ├── monitoring.yaml │ │ │ ├── nats.yaml │ │ │ └── rbac.yaml │ │ └── values.yaml │ ├── rbac.yml │ ├── server.go │ ├── test │ │ ├── handlers_test.go │ │ └── read_config_test.go │ ├── types │ │ ├── read_config.go │ │ └── requests.go │ └── vendor.conf ├── faas-provider │ ├── .gitignore │ ├── Dockerfile │ ├── LICENSE │ ├── README.md │ ├── serve.go │ ├── types │ │ ├── config.go │ │ └── requests.go │ └── vendor.conf └── faas │ ├── .DEREK.yml │ ├── .github │ ├── ISSUE_TEMPLATE.md │ └── PULL_REQUEST_TEMPLATE.md │ ├── .gitignore │ ├── .travis.yml │ ├── BACKERS.md │ ├── CNAME │ ├── CONTRIBUTING.md │ ├── DEV.md │ ├── LICENSE │ ├── MAINTAINERS │ ├── Makefile │ ├── README.md │ ├── ROADMAP.md │ ├── TestDrive.md │ ├── _config.yml │ ├── api-docs │ ├── README.md │ └── swagger.yml │ ├── appveyor.yml │ ├── build.sh │ ├── community.md │ ├── contrib │ ├── HACK.md │ ├── ci.sh │ ├── dind │ │ ├── Dockerfile │ │ ├── entry.sh │ │ ├── start.sh │ │ └── test.sh │ ├── golang │ │ └── Dockerfile │ ├── grafana.json │ ├── nginx │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ └── gateway.conf │ └── prometheus │ │ └── Dockerfile │ ├── debug.md │ ├── deploy_extended.sh │ ├── deploy_stack.armhf.sh │ ├── deploy_stack.ps1 │ ├── deploy_stack.sh │ ├── docker-compose.arm64.yml │ ├── docker-compose.armhf.yml │ ├── docker-compose.extended.armhf.yml │ ├── docker-compose.extended.yml │ ├── docker-compose.yml │ ├── docs │ ├── CNAME │ ├── README.md │ ├── _config.yml │ └── managing-images.md │ ├── gateway │ ├── .gitignore │ ├── Dockerfile │ ├── Dockerfile.arm64 │ ├── Dockerfile.armhf │ ├── README.md │ ├── assets │ │ ├── android-chrome-192x192.png │ │ ├── android-chrome-256x256.png │ │ ├── apple-touch-icon.png │ │ ├── browserconfig.xml │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon.ico │ │ ├── icon.png │ │ ├── img │ │ │ └── icons │ │ │ │ ├── ic_arrow_back_white.svg │ │ │ │ ├── ic_close_24px.svg │ │ │ │ ├── ic_delete_black.svg │ │ │ │ ├── ic_info_outline_black_24px.svg │ │ │ │ ├── ic_menu_white.svg │ │ │ │ ├── ic_search_black_24px.svg │ │ │ │ └── ic_shop_two_black_24px.svg │ │ ├── index.html │ │ ├── manifest.json │ │ ├── mstile-150x150.png │ │ ├── safari-pinned-tab.svg │ │ ├── script │ │ │ ├── bootstrap.js │ │ │ └── funcstore.js │ │ ├── style │ │ │ └── bootstrap.css │ │ └── templates │ │ │ ├── funcstore.html │ │ │ └── newfunction.html │ ├── build.sh │ ├── handlers │ │ ├── alerthandler.go │ │ ├── asyncreport.go │ │ ├── cors.go │ │ ├── create_handler.go │ │ ├── deletehandler.go │ │ ├── forwarding_proxy.go │ │ ├── proxy.go │ │ ├── queueproxy.go │ │ ├── reader.go │ │ └── update_handler.go │ ├── metrics │ │ ├── add_metrics.go │ │ ├── externalwatcher.go │ │ ├── metrics.go │ │ ├── prometheus_query.go │ │ └── swarmwatcher.go │ ├── plugin │ │ └── external.go │ ├── queue │ │ └── types.go │ ├── requests │ │ ├── forward_request.go │ │ ├── prometheus.go │ │ └── requests.go │ ├── server.go │ ├── tests │ │ ├── add_metrics_test.go │ │ ├── alerthandler_test.go │ │ ├── alexhostname_request.json │ │ ├── config_test.go │ │ ├── forward_request_test.go │ │ ├── integration │ │ │ ├── README.md │ │ │ ├── createfunction_test.go │ │ │ ├── deletefunction_test.go │ │ │ └── routes_test.go │ │ ├── proxy_test.go │ │ ├── reader_test.go │ │ ├── registryauth_test.go │ │ ├── resources_test.go │ │ ├── test_alert.json │ │ ├── test_resolved_alert.json │ │ └── unmarshall_test.go │ ├── types │ │ ├── http_adapter.go │ │ └── readconfig.go │ └── vendor.conf │ ├── guide │ ├── README.md │ ├── asynchronous.md │ ├── backends.md │ ├── chaining_functions.md │ ├── deployment_digitalocean.md │ ├── deployment_k8s.md │ ├── deployment_swarm.md │ ├── deployment_swarm_arm.md │ ├── interactions.md │ ├── kong_integration.md │ ├── performance_testing.md │ ├── traefik_integration.md │ └── troubleshooting.md │ ├── prometheus │ ├── Dockerfile.alertmanager │ ├── Dockerfile.alertmanager.k8s │ ├── Dockerfile.prometheus │ ├── Dockerfile.prometheus.k8s │ ├── alert.rules │ ├── alertmanager.yml │ ├── k8s.alert.rules │ ├── k8s.alertmanager.yml │ ├── k8s.prometheus.yml │ └── prometheus.yml │ ├── sample-functions │ ├── .gitignore │ ├── AlpineFunction │ │ ├── Dockerfile │ │ ├── Dockerfile.arm64 │ │ ├── Dockerfile.armhf │ │ ├── README.md │ │ └── build.armhf.sh │ ├── ApiKeyProtected │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ └── handler.go │ ├── BaseFunctions │ │ ├── R │ │ │ ├── Dockerfile │ │ │ ├── README.Rmd │ │ │ ├── README.md │ │ │ ├── build.sh │ │ │ └── handler.R │ │ ├── README.md │ │ ├── cobol │ │ │ ├── Dockerfile │ │ │ ├── README.md │ │ │ ├── build.sh │ │ │ ├── handler.cob │ │ │ └── hello.cob │ │ ├── coffee │ │ │ ├── Dockerfile │ │ │ ├── build.sh │ │ │ ├── handler.coffee │ │ │ └── package.json │ │ ├── dncore │ │ │ ├── Dockerfile │ │ │ └── src │ │ │ │ ├── .gitignore │ │ │ │ ├── Program.cs │ │ │ │ └── root.csproj │ │ ├── golang │ │ │ ├── Dockerfile │ │ │ ├── Dockerfile.win │ │ │ ├── README.md │ │ │ ├── build.sh │ │ │ └── handler.go │ │ ├── java │ │ │ ├── .gitignore │ │ │ ├── Dockerfile │ │ │ ├── Handler.java │ │ │ └── build.sh │ │ ├── node │ │ │ ├── Dockerfile │ │ │ ├── build.sh │ │ │ ├── handler.js │ │ │ └── package.json │ │ └── python │ │ │ ├── Dockerfile │ │ │ ├── build.sh │ │ │ └── handler.py │ ├── CHelloWorld │ │ ├── .gitignore │ │ ├── README.md │ │ ├── src │ │ │ ├── Dockerfile │ │ │ └── main.c │ │ └── stack.yml │ ├── CaptainsIntent │ │ ├── Dockerfile │ │ ├── handler.js │ │ ├── oneshot.txt │ │ ├── package.json │ │ ├── parser.js │ │ ├── request.json │ │ ├── run.sh │ │ └── sample.json │ ├── ChangeColorIntent │ │ ├── Dockerfile │ │ ├── blue.json │ │ ├── build.sh │ │ ├── green.json │ │ ├── handler.js │ │ ├── off.json │ │ ├── oneshot.txt │ │ ├── package.json │ │ ├── red.json │ │ ├── sample_request.json │ │ ├── sample_response.json │ │ └── sendColor.js │ ├── DockerHubStats │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── Dockerfile.armhf │ │ ├── Makefile │ │ └── main.go │ ├── HostnameIntent │ │ ├── Dockerfile │ │ ├── handler.js │ │ ├── oneshot.txt │ │ ├── package.json │ │ └── sample.json │ ├── MarkdownRender │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── Gopkg.lock │ │ ├── Gopkg.toml │ │ ├── MarkdownRender │ │ └── handler.go │ ├── NodeInfo │ │ ├── Dockerfile │ │ ├── Dockerfile.arm64 │ │ ├── Dockerfile.armhf │ │ ├── Dockerfile.func │ │ ├── build.armhf.sh │ │ ├── build.func.sh │ │ ├── build.sh │ │ ├── handler.js │ │ ├── main.js │ │ └── package.json │ ├── Phantomjs │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── cnn.js │ │ └── feedly_subscribers.js │ ├── README.md │ ├── ResizeImageMagick │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── Dockerfile.armhf │ │ ├── README.md │ │ ├── build.armhf.sh │ │ ├── build.sh │ │ └── gordon.png │ ├── SentimentAnalysis │ │ ├── Dockerfile │ │ ├── Dockerfile.armhf │ │ ├── README.md │ │ ├── build.armhf.sh │ │ ├── build.sh │ │ └── handler.py │ ├── WebhookStash │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ └── handler.go │ ├── WordCountFunction │ │ ├── Dockerfile │ │ └── build.sh │ ├── build_all.sh │ ├── echo │ │ └── Dockerfile │ ├── gif-maker │ │ ├── Dockerfile │ │ ├── README.md │ │ └── entry.sh │ └── samples.yml │ └── watchdog │ ├── .gitignore │ ├── Dockerfile │ ├── Makefile │ ├── README.md │ ├── build.ps1 │ ├── build.sh │ ├── config_test.go │ ├── main.go │ ├── readconfig.go │ ├── requesthandler_test.go │ └── types │ └── types.go └── realbot └── faas-provider ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── serve.go ├── types ├── config.go └── requests.go └── vendor.conf /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 14 | .glide/ 15 | 16 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 17 | *.o 18 | *.a 19 | *.so 20 | 21 | *.prof 22 | .vscode 23 | .DS_Store 24 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.9.2 2 | 3 | RUN mkdir -p /go/src/github.com/realbot/faas-dcos/ 4 | 5 | WORKDIR /go/src/github.com/realbot/faas-dcos 6 | 7 | COPY vendor vendor 8 | COPY handlers handlers 9 | #COPY types types 10 | COPY read_config.go . 11 | COPY server.go . 12 | 13 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-dcos . 14 | 15 | RUN /bin/bash -c 'source $HOME/.bashrc; echo $HOME' 16 | 17 | FROM alpine:3.6 18 | RUN apk --no-cache add ca-certificates 19 | WORKDIR /root/ 20 | 21 | EXPOSE 8080 22 | ENV http_proxy "" 23 | ENV https_proxy "" 24 | 25 | COPY --from=0 /go/src/github.com/realbot/faas-dcos/faas-dcos . 26 | 27 | CMD ["./faas-dcos"] -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | 24 | [[constraint]] 25 | name = "github.com/gambol99/go-marathon" 26 | version = "0.7.1" 27 | 28 | [[constraint]] 29 | name = "github.com/gorilla/mux" 30 | version = "1.6.0" 31 | 32 | [[constraint]] 33 | name = "github.com/openfaas/faas" 34 | version = "0.6.13" 35 | 36 | [[constraint]] 37 | name = "github.com/openfaas/faas-netes" 38 | version = "0.3.9" 39 | 40 | [[constraint]] 41 | name = "github.com/openfaas/faas-provider" 42 | version = "0.4.0" 43 | 44 | [[constraint]] 45 | name = "github.com/realbot/faas-provider" 46 | version = "0.3.0" 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alex Ellis 4 | Copyright (c) 2017 Alberto Quario 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TAG?=0.2 2 | 3 | build: 4 | docker build --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) -t realbot/faas-dcos:$(TAG) . 5 | 6 | push: 7 | docker push realbot/faas-dcos:$(TAG) -------------------------------------------------------------------------------- /docs/images/function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/docs/images/function.png -------------------------------------------------------------------------------- /docs/images/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/docs/images/install.png -------------------------------------------------------------------------------- /docs/images/invoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/docs/images/invoke.png -------------------------------------------------------------------------------- /docs/images/mlb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/docs/images/mlb.png -------------------------------------------------------------------------------- /functions.yml: -------------------------------------------------------------------------------- 1 | provider: 2 | name: faas 3 | gateway: http://:10012 4 | 5 | functions: 6 | nodeinfo: 7 | fprocess: node main.js 8 | image: functions/nodeinfo:latest 9 | skip_build: true 10 | labels: 11 | com.openfaas.scale.min: "5" 12 | com.openfaas.scale.max: "15" 13 | requests: 14 | memory: 256 15 | -------------------------------------------------------------------------------- /handlers/common.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017, Alberto Quario 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package handlers 5 | 6 | import "strings" 7 | 8 | func Function2ID(functionName string) string { 9 | return "/faas/functions/" + functionName 10 | } 11 | 12 | func ID2Function(ID string) string { 13 | return strings.TrimPrefix(ID, "/faas/functions/") 14 | } 15 | 16 | func Function2Endpoint(functionName string) string { 17 | return "functions-" + functionName 18 | } 19 | -------------------------------------------------------------------------------- /handlers/health.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017, Alberto Quario 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package handlers 5 | 6 | import ( 7 | "fmt" 8 | "net/http" 9 | 10 | marathon "github.com/gambol99/go-marathon" 11 | ) 12 | 13 | // MakeHealthHandler creates a handler to check health 14 | func MakeHealthHandler(client marathon.Marathon) http.HandlerFunc { 15 | return func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "OK") } 16 | } 17 | -------------------------------------------------------------------------------- /handlers/reader.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017, Alberto Quario 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package handlers 5 | 6 | import ( 7 | "encoding/json" 8 | "log" 9 | "net/http" 10 | "net/url" 11 | 12 | marathon "github.com/gambol99/go-marathon" 13 | "github.com/openfaas/faas/gateway/requests" 14 | ) 15 | 16 | func getServiceList(client marathon.Marathon) ([]requests.Function, error) { 17 | var functions []requests.Function 18 | 19 | v := url.Values{} 20 | v.Set("label", "faas_function") 21 | applications, err := client.Applications(v) 22 | 23 | if err != nil { 24 | return nil, err 25 | } 26 | for _, item := range applications.Apps { 27 | function := requests.Function{ 28 | Name: ID2Function(item.ID), 29 | Replicas: uint64(item.TasksRunning), 30 | Image: item.Container.Docker.Image, 31 | InvocationCount: 0, 32 | } 33 | functions = append(functions, function) 34 | } 35 | return functions, nil 36 | } 37 | 38 | // MakeFunctionReader handler for reading functions deployed in the cluster as deployments. 39 | func MakeFunctionReader(client marathon.Marathon) http.HandlerFunc { 40 | return func(w http.ResponseWriter, r *http.Request) { 41 | 42 | functions, err := getServiceList(client) 43 | if err != nil { 44 | log.Println(err) 45 | w.WriteHeader(500) 46 | w.Write([]byte(err.Error())) 47 | return 48 | } 49 | 50 | functionBytes, _ := json.Marshal(functions) 51 | w.Header().Set("Content-Type", "application/json") 52 | w.WriteHeader(200) 53 | w.Write(functionBytes) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /prometheus/Dockerfile.alertmanager.dcos: -------------------------------------------------------------------------------- 1 | FROM prom/alertmanager:v0.7.1 2 | 3 | COPY dcos.alertmanager.yml /alertmanager.yml 4 | -------------------------------------------------------------------------------- /prometheus/Dockerfile.prometheus.dcos: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus:v1.5.2 2 | 3 | COPY dcos.prometheus.yml /etc/prometheus/prometheus.yml 4 | COPY dcos.alert.rules /etc/prometheus/alert.rules 5 | 6 | -------------------------------------------------------------------------------- /prometheus/Makefile: -------------------------------------------------------------------------------- 1 | TAG?=latest 2 | 3 | build: 4 | docker build --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) -f Dockerfile.alertmanager.dcos -t realbot/alertmanager:$(TAG) . 5 | docker build --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) -f Dockerfile.prometheus.dcos -t realbot/prometheus:$(TAG) . 6 | 7 | push: 8 | docker push realbot/alertmanager:$(TAG) 9 | docker push realbot/prometheus:$(TAG) -------------------------------------------------------------------------------- /prometheus/dcos.alert.rules: -------------------------------------------------------------------------------- 1 | ALERT service_down 2 | IF up == 0 3 | 4 | ALERT APIHighInvocationRate 5 | IF sum ( rate(gateway_function_invocation_total{code="200"}[10s]) ) by (function_name) > 5 6 | FOR 5s 7 | LABELS { 8 | service = "gateway", 9 | severity = "major", 10 | value = "{{$value}}" 11 | } 12 | ANNOTATIONS { 13 | summary = "High invocation total on {{ $labels.instance }}", 14 | description = "High invocation total on {{ $labels.instance }}" 15 | } 16 | 17 | -------------------------------------------------------------------------------- /prometheus/dcos.prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # By default, scrape targets every 15 seconds. 4 | evaluation_interval: 15s # By default, scrape targets every 15 seconds. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | monitor: 'faas-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | - 'alert.rules' 15 | 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # Override the global default and scrape targets from this job every 5 seconds. 24 | scrape_interval: 5s 25 | 26 | # metrics_path defaults to '/metrics' 27 | # scheme defaults to 'http'. 28 | static_configs: 29 | - targets: ['localhost:9090'] 30 | 31 | - job_name: "gateway" 32 | scrape_interval: 5s 33 | dns_sd_configs: 34 | - names: ['marathon-lb.marathon.mesos'] 35 | port: 10012 36 | type: A 37 | refresh_interval: 5s 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/donovanhide/eventsource?status.svg)](http://godoc.org/github.com/donovanhide/eventsource) 2 | [![CircleCI](https://circleci.com/gh/donovanhide/eventsource.svg?style=svg)](https://circleci.com/gh/donovanhide/eventsource) 3 | 4 | 5 | # Eventsource 6 | 7 | Eventsource implements a [Go](http://golang.org/) implementation of client and server to allow streaming data one-way over a HTTP connection using the Server-Sent Events API http://dev.w3.org/html5/eventsource/ 8 | 9 | ## Installation 10 | 11 | go get github.com/donovanhide/eventsource 12 | 13 | ## Documentation 14 | 15 | * [Reference](http://godoc.org/github.com/donovanhide/eventsource) 16 | 17 | ## License 18 | 19 | Eventsource is available under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html). 20 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/codec_test.go: -------------------------------------------------------------------------------- 1 | package eventsource 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | ) 7 | 8 | type testEvent struct { 9 | id, event, data string 10 | } 11 | 12 | func (e *testEvent) Id() string { return e.id } 13 | func (e *testEvent) Event() string { return e.event } 14 | func (e *testEvent) Data() string { return e.data } 15 | 16 | var encoderTests = []struct { 17 | event *testEvent 18 | output string 19 | }{ 20 | {&testEvent{"1", "Add", "This is a test"}, "id: 1\nevent: Add\ndata: This is a test\n\n"}, 21 | {&testEvent{"", "", "This message, it\nhas two lines."}, "data: This message, it\ndata: has two lines.\n\n"}, 22 | } 23 | 24 | func TestRoundTrip(t *testing.T) { 25 | buf := new(bytes.Buffer) 26 | enc := NewEncoder(buf, false) 27 | dec := NewDecoder(buf) 28 | for _, tt := range encoderTests { 29 | want := tt.event 30 | if err := enc.Encode(want); err != nil { 31 | t.Fatal(err) 32 | } 33 | if buf.String() != tt.output { 34 | t.Errorf("Expected: %s Got: %s", tt.output, buf.String()) 35 | } 36 | ev, err := dec.Decode() 37 | if err != nil { 38 | t.Fatal(err) 39 | } 40 | if ev.Id() != want.Id() || ev.Event() != want.Event() || ev.Data() != want.Data() { 41 | t.Errorf("Expected: %s %s %s Got: %s %s %s", want.Id(), want.Event(), want.Data(), ev.Id(), ev.Event(), ev.Data()) 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/decoder_test.go: -------------------------------------------------------------------------------- 1 | package eventsource 2 | 3 | import ( 4 | "io" 5 | "reflect" 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | func TestDecode(t *testing.T) { 11 | tests := []struct { 12 | rawInput string 13 | wantedEvents []*publication 14 | }{ 15 | { 16 | rawInput: "event: eventName\ndata: {\"sample\":\"value\"}\n\n", 17 | wantedEvents: []*publication{{event: "eventName", data: "{\"sample\":\"value\"}"}}, 18 | }, 19 | { 20 | // the newlines should not be parsed as empty event 21 | rawInput: "\n\n\nevent: event1\n\n\n\n\nevent: event2\n\n", 22 | wantedEvents: []*publication{{event: "event1"}, {event: "event2"}}, 23 | }, 24 | } 25 | 26 | for _, test := range tests { 27 | decoder := NewDecoder(strings.NewReader(test.rawInput)) 28 | i := 0 29 | for { 30 | event, err := decoder.Decode() 31 | if err == io.EOF { 32 | break 33 | } 34 | if err != nil { 35 | t.Fatalf("Unexpected error on decoding event: %s", err) 36 | } 37 | 38 | if !reflect.DeepEqual(event, test.wantedEvents[i]) { 39 | t.Fatalf("Parsed event %+v does not equal wanted event %+v", event, test.wantedEvents[i]) 40 | } 41 | i++ 42 | } 43 | if i != len(test.wantedEvents) { 44 | t.Fatalf("Unexpected number of events: %d does not equal wanted: %d", i, len(test.wantedEvents)) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/encoder.go: -------------------------------------------------------------------------------- 1 | package eventsource 2 | 3 | import ( 4 | "compress/gzip" 5 | "fmt" 6 | "io" 7 | "strings" 8 | ) 9 | 10 | var ( 11 | encFields = []struct { 12 | prefix string 13 | value func(Event) string 14 | }{ 15 | {"id: ", Event.Id}, 16 | {"event: ", Event.Event}, 17 | {"data: ", Event.Data}, 18 | } 19 | ) 20 | 21 | // An Encoder is capable of writing Events to a stream. Optionally 22 | // Events can be gzip compressed in this process. 23 | type Encoder struct { 24 | w io.Writer 25 | compressed bool 26 | } 27 | 28 | // NewEncoder returns an Encoder for a given io.Writer. 29 | // When compressed is set to true, a gzip writer will be 30 | // created. 31 | func NewEncoder(w io.Writer, compressed bool) *Encoder { 32 | if compressed { 33 | return &Encoder{w: gzip.NewWriter(w), compressed: true} 34 | } 35 | return &Encoder{w: w} 36 | } 37 | 38 | // Encode writes an event in the format specified by the 39 | // server-sent events protocol. 40 | func (enc *Encoder) Encode(ev Event) error { 41 | for _, field := range encFields { 42 | prefix, value := field.prefix, field.value(ev) 43 | if len(value) == 0 { 44 | continue 45 | } 46 | value = strings.Replace(value, "\n", "\n"+prefix, -1) 47 | if _, err := io.WriteString(enc.w, prefix+value+"\n"); err != nil { 48 | return fmt.Errorf("eventsource encode: %v", err) 49 | } 50 | } 51 | if _, err := io.WriteString(enc.w, "\n"); err != nil { 52 | return fmt.Errorf("eventsource encode: %v", err) 53 | } 54 | if enc.compressed { 55 | return enc.w.(*gzip.Writer).Flush() 56 | } 57 | return nil 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/example_error_handling_stream_test.go: -------------------------------------------------------------------------------- 1 | package eventsource_test 2 | 3 | import ( 4 | "fmt" 5 | "github.com/donovanhide/eventsource" 6 | "net" 7 | "net/http" 8 | ) 9 | 10 | func ExampleErrorHandlingStream() { 11 | listener, err := net.Listen("tcp", ":8080") 12 | if err != nil { 13 | return 14 | } 15 | defer listener.Close() 16 | http.HandleFunc("/stream", func(w http.ResponseWriter, r *http.Request) { 17 | http.Error(w, "Something wrong.", 500) 18 | }) 19 | go http.Serve(listener, nil) 20 | 21 | _, err = eventsource.Subscribe("http://127.0.0.1:8080/stream", "") 22 | if err != nil { 23 | if serr, ok := err.(eventsource.SubscriptionError); ok { 24 | fmt.Printf("Status code: %d\n", serr.Code) 25 | fmt.Printf("Message: %s\n", serr.Message) 26 | } else { 27 | fmt.Println("failed to subscribe") 28 | } 29 | } 30 | 31 | // Output: 32 | // Status code: 500 33 | // Message: Something wrong. 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/interface.go: -------------------------------------------------------------------------------- 1 | // Package eventsource implements a client and server to allow streaming data one-way over a HTTP connection 2 | // using the Server-Sent Events API http://dev.w3.org/html5/eventsource/ 3 | // 4 | // The client and server respect the Last-Event-ID header. 5 | // If the Repository interface is implemented on the server, events can be replayed in case of a network disconnection. 6 | package eventsource 7 | 8 | // Any event received by the client or sent by the server will implement this interface 9 | type Event interface { 10 | // Id is an identifier that can be used to allow a client to replay 11 | // missed Events by returning the Last-Event-Id header. 12 | // Return empty string if not required. 13 | Id() string 14 | // The name of the event. Return empty string if not required. 15 | Event() string 16 | // The payload of the event. 17 | Data() string 18 | } 19 | 20 | // If history is required, this interface will allow clients to reply previous events through the server. 21 | // Both methods can be called from different goroutines concurrently, so you must make sure they are go-routine safe. 22 | type Repository interface { 23 | // Gets the Events which should follow on from the specified channel and event id. 24 | Replay(channel, id string) chan Event 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/normalise.go: -------------------------------------------------------------------------------- 1 | package eventsource 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // A reader which normalises line endings 8 | // "/r" and "/r/n" are converted to "/n" 9 | type normaliser struct { 10 | r io.Reader 11 | lastChar byte 12 | } 13 | 14 | func newNormaliser(r io.Reader) *normaliser { 15 | return &normaliser{r: r} 16 | } 17 | 18 | func (norm *normaliser) Read(p []byte) (n int, err error) { 19 | n, err = norm.r.Read(p) 20 | for i := 0; i < n; i++ { 21 | switch { 22 | case p[i] == '\n' && norm.lastChar == '\r': 23 | copy(p[i:n], p[i+1:]) 24 | norm.lastChar = p[i] 25 | n-- 26 | i-- 27 | case p[i] == '\r': 28 | norm.lastChar = p[i] 29 | p[i] = '\n' 30 | default: 31 | norm.lastChar = p[i] 32 | } 33 | } 34 | return 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/normalise_test.go: -------------------------------------------------------------------------------- 1 | package eventsource 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | var ( 11 | inputFormat = "line1%sline2%sline3%s" 12 | endings = []string{"\n", "\r\n", "\r"} 13 | suffixes = []string{"\n", "\r\n", "\r", ""} 14 | descriptions = []string{"LF", "CRLF", "CR", "EOF"} 15 | expected = []string{"line1", "line2", "line3"} 16 | ) 17 | 18 | func Testnormaliser(t *testing.T) { 19 | for i, first := range endings { 20 | for j, second := range endings { 21 | for k, suffix := range suffixes { 22 | input := fmt.Sprintf(inputFormat, first, second, suffix) 23 | r := bufio.NewReader(newNormaliser(strings.NewReader(input))) 24 | for _, want := range expected { 25 | line, err := r.ReadString('\n') 26 | if err != nil && suffix != "" { 27 | t.Error("Unexpected error:", err) 28 | } 29 | line = strings.TrimSuffix(line, "\n") 30 | if line != want { 31 | expanded := fmt.Sprintf(inputFormat, descriptions[i], descriptions[j], descriptions[k]) 32 | t.Errorf(`Using %s Expected: "%s" Got: "%s"`, expanded, want, line) 33 | t.Log([]byte(line)) 34 | } 35 | } 36 | if _, err := r.ReadString('\n'); err == nil { 37 | t.Error("Expected EOF") 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/repository.go: -------------------------------------------------------------------------------- 1 | package eventsource 2 | 3 | import ( 4 | "sort" 5 | "sync" 6 | ) 7 | 8 | // Example repository that uses a slice as storage for past events. 9 | type SliceRepository struct { 10 | events map[string][]Event 11 | lock sync.RWMutex 12 | } 13 | 14 | func NewSliceRepository() *SliceRepository { 15 | return &SliceRepository{ 16 | events: make(map[string][]Event), 17 | } 18 | } 19 | 20 | func (repo SliceRepository) indexOfEvent(channel, id string) int { 21 | return sort.Search(len(repo.events[channel]), func(i int) bool { 22 | return repo.events[channel][i].Id() >= id 23 | }) 24 | } 25 | 26 | func (repo SliceRepository) Replay(channel, id string) (out chan Event) { 27 | out = make(chan Event) 28 | go func() { 29 | defer close(out) 30 | repo.lock.RLock() 31 | defer repo.lock.RUnlock() 32 | events := repo.events[channel][repo.indexOfEvent(channel, id):] 33 | for i := range events { 34 | out <- events[i] 35 | } 36 | }() 37 | return 38 | } 39 | 40 | func (repo *SliceRepository) Add(channel string, event Event) { 41 | repo.lock.Lock() 42 | defer repo.lock.Unlock() 43 | i := repo.indexOfEvent(channel, event.Id()) 44 | if i < len(repo.events[channel]) && repo.events[channel][i].Id() == event.Id() { 45 | repo.events[channel][i] = event 46 | } else { 47 | repo.events[channel] = append(repo.events[channel][:i], append([]Event{event}, repo.events[channel][i:]...)...) 48 | } 49 | return 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/donovanhide/eventsource/server_test.go: -------------------------------------------------------------------------------- 1 | package eventsource 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestNewServerHandlerRespondsAfterClose(t *testing.T) { 11 | server := NewServer() 12 | httpServer := httptest.NewServer(server.Handler("test")) 13 | defer httpServer.Close() 14 | 15 | server.Close() 16 | responses := make(chan *http.Response) 17 | 18 | go func() { 19 | resp, err := http.Get(httpServer.URL) 20 | if err != nil { 21 | t.Fatalf("Unexpected error %s", err) 22 | } 23 | responses <- resp 24 | }() 25 | 26 | select { 27 | case resp := <-responses: 28 | if resp.StatusCode != 200 { 29 | t.Errorf("Received StatusCode %d, want 200", resp.StatusCode) 30 | } 31 | case <-time.After(250 * time.Millisecond): 32 | t.Errorf("Did not receive response in time") 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | go-marathon.iml 6 | .idea/ 7 | Gemfile.lock 8 | thin.* 9 | examples/applications/applications 10 | examples/events_callback_transport/events_callback_transport 11 | examples/events_sse_transport/events_sse_transport 12 | examples/glog/glog 13 | examples/groups/groups 14 | examples/multiple_endpoints/multiple_endpoints 15 | examples/queue/queue 16 | examples/tasks/tasks 17 | 18 | # Folders 19 | _obj 20 | _test 21 | 22 | # Architecture specific extensions/prefixes 23 | *.[568vq] 24 | [568vq].out 25 | 26 | *.cgo1.go 27 | *.cgo2.c 28 | _cgo_defun.c 29 | _cgo_gotypes.go 30 | _cgo_export.* 31 | 32 | _testmain.go 33 | 34 | *.exe 35 | *.test 36 | *.prof 37 | 38 | tests/rest-api/rest-api 39 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/.travis.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Rohith (gambol99@gmail.com) 3 | # Date: 2015-02-17 17:11:18 +0000 (Tue, 17 Feb 2015) 4 | # 5 | # vim:ts=2:sw=2:et 6 | # 7 | language: go 8 | go: 9 | - 1.5 10 | - 1.6 11 | - 1.7 12 | - 1.8 13 | install: 14 | - make check-format test examples 15 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | ## Pre-Development 4 | - Look for an existing Github issue describing the bug you have found/feature request you would like to see getting implemented. 5 | - If no issue exists and there is reason to believe that your (non-trivial) contribution might be subject to an up-front design discussion, file an issue first and propose your idea. 6 | 7 | ## Development 8 | - Fork the repository. 9 | - Create a feature branch (`git checkout -b my-new-feature master`). 10 | - Commit your changes, preferring one commit per logical unit of work. Often times, this simply means having a single commit. 11 | - If applicable, update the documentation in the [README file](README.md). 12 | - In the vast majority of cases, you should add/amend a (regression) test for your bug fix/feature. 13 | - Push your branch (`git push origin my-new-feature`). 14 | - Create a new pull request. 15 | - Address any comments your reviewer raises, pushing additional commits onto your branch along the way. In particular, refrain from amending/force-pushing until you receive an LGTM (Looks Good To Me) from your reviewer. This will allow for a better review experience. 16 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/examples/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | find * -type d -exec bash -exc "cd {}; go build . || kill $${PPID}" \; 3 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/examples/docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Based on https://github.com/meltwater/docker-mesos 2 | 3 | zookeeper: 4 | image: mesoscloud/zookeeper:3.4.6-centos-7 5 | ports: 6 | - "2181:2181" 7 | - "2888:2888" 8 | - "3888:3888" 9 | environment: 10 | SERVERS: server.1=127.0.0.1 11 | MYID: 1 12 | 13 | mesosmaster: 14 | image: mesoscloud/mesos-master:0.24.1-centos-7 15 | net: host 16 | environment: 17 | MESOS_ZK: zk://localhost:2181/mesos 18 | MESOS_QUORUM: 1 19 | MESOS_CLUSTER: local 20 | MESOS_HOSTNAME: localhost 21 | 22 | mesosslave: 23 | image: mesoscloud/mesos-slave:0.24.1-centos-7 24 | net: host 25 | privileged: true 26 | volumes: 27 | - /sys:/sys 28 | # /cgroup is needed on some older Linux versions 29 | # - /cgroup:/cgroup 30 | # /usr/bin/docker is needed if you're running an older docker version 31 | # - /usr/local/bin/docker:/usr/bin/docker:r 32 | - /var/run/docker.sock:/var/run/docker.sock:rw 33 | environment: 34 | MESOS_MASTER: zk://localhost:2181/mesos 35 | MESOS_EXECUTOR_SHUTDOWN_GRACE_PERIOD: 90secs 36 | MESOS_DOCKER_STOP_TIMEOUT: 60secs 37 | # If your workstation doesn't have a resolvable hostname/FQDN then $MESOS_HOSTNAME needs to be set to its IP-address 38 | # MESOS_HOSTNAME: 192.168.178.39 39 | 40 | marathon: 41 | image: mesoscloud/marathon:0.11.0-centos-7 42 | net: host 43 | environment: 44 | MARATHON_ZK: zk://localhost:2181/marathon 45 | MARATHON_MASTER: zk://localhost:2181/mesos 46 | MARATHON_EVENT_SUBSCRIBER: http_callback 47 | MARATHON_TASK_LAUNCH_TIMEOUT: 300000 48 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/examples/glog/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, software 9 | distributed under the License is distributed on an "AS IS" BASIS, 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | See the License for the specific language governing permissions and 12 | limitations under the License. 13 | */ 14 | 15 | // go run main.go -logtostderr 16 | 17 | package main 18 | 19 | import ( 20 | "flag" 21 | 22 | marathon "github.com/gambol99/go-marathon" 23 | "github.com/golang/glog" 24 | ) 25 | 26 | var marathonURL string 27 | 28 | type logBridge struct{} 29 | 30 | func (l *logBridge) Write(b []byte) (n int, err error) { 31 | glog.InfoDepth(3, "go-marathon: "+string(b)) 32 | return len(b), nil 33 | } 34 | 35 | func init() { 36 | flag.StringVar(&marathonURL, "url", "http://127.0.0.1:8080", "the url for the marathon endpoint") 37 | } 38 | 39 | func main() { 40 | flag.Parse() 41 | config := marathon.NewDefaultConfig() 42 | config.URL = marathonURL 43 | config.LogOutput = new(logBridge) 44 | client, err := marathon.NewClient(config) 45 | if err != nil { 46 | glog.Exitln(err) 47 | } 48 | 49 | applications, err := client.Applications(nil) 50 | if err != nil { 51 | glog.Exitln(err) 52 | } 53 | 54 | for _, a := range applications.Apps { 55 | glog.Infof("App ID: %v\n", a.ID) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/examples/tasks/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | marathon "github.com/gambol99/go-marathon" 8 | ) 9 | 10 | const marathonURL = "http://127.0.0.1:8080" 11 | 12 | func main() { 13 | config := marathon.NewDefaultConfig() 14 | config.URL = marathonURL 15 | client, err := marathon.NewClient(config) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | app := marathon.Application{} 21 | app.ID = "tasks-test" 22 | app.Command("sleep 60") 23 | app.Count(3) 24 | fmt.Println("Creating app.") 25 | // Update application will either create or update the app. 26 | _, err = client.UpdateApplication(&app, false) 27 | if err != nil { 28 | panic(err) 29 | } 30 | 31 | // wait until marathon will launch tasks 32 | client.WaitOnApplication(app.ID, 10*time.Second) 33 | fmt.Println("Tasks were deployed.") 34 | 35 | tasks, err := client.Tasks(app.ID) 36 | if err != nil { 37 | panic(err) 38 | } 39 | 40 | host := tasks.Tasks[0].Host 41 | fmt.Printf("Killing tasks on the host: %s\n", host) 42 | 43 | _, err = client.KillApplicationTasks(app.ID, &marathon.KillApplicationTasksOpts{Scale: true, Host: host}) 44 | if err != nil { 45 | panic(err) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/last_task_failure.go: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | */ 15 | 16 | package marathon 17 | 18 | // LastTaskFailure provides details on the last error experienced by an application 19 | type LastTaskFailure struct { 20 | AppID string `json:"appId,omitempty"` 21 | Host string `json:"host,omitempty"` 22 | Message string `json:"message,omitempty"` 23 | State string `json:"state,omitempty"` 24 | TaskID string `json:"taskId,omitempty"` 25 | Timestamp string `json:"timestamp,omitempty"` 26 | Version string `json:"version,omitempty"` 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/queue_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2016 Rohith All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package marathon 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/assert" 23 | ) 24 | 25 | func TestQueue(t *testing.T) { 26 | endpoint := newFakeMarathonEndpoint(t, nil) 27 | defer endpoint.Close() 28 | 29 | queue, err := endpoint.Client.Queue() 30 | assert.NoError(t, err) 31 | assert.NotNil(t, queue) 32 | 33 | assert.Len(t, queue.Items, 1) 34 | item := queue.Items[0] 35 | assert.Equal(t, item.Count, 10) 36 | assert.Equal(t, item.Delay.Overdue, true) 37 | assert.Equal(t, item.Delay.TimeLeftSeconds, 784) 38 | assert.NotEmpty(t, item.Application.ID) 39 | } 40 | 41 | func TestDeleteQueueDelay(t *testing.T) { 42 | endpoint := newFakeMarathonEndpoint(t, nil) 43 | defer endpoint.Close() 44 | 45 | err := endpoint.Client.DeleteQueueDelay(fakeAppName) 46 | assert.NoError(t, err) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/gambol99/go-marathon/update_strategy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Rohith All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package marathon 18 | 19 | // UpgradeStrategy is the upgrade strategy applied to an application. 20 | type UpgradeStrategy struct { 21 | MinimumHealthCapacity *float64 `json:"minimumHealthCapacity,omitempty"` 22 | MaximumOverCapacity *float64 `json:"maximumOverCapacity,omitempty"` 23 | } 24 | 25 | // SetMinimumHealthCapacity sets the minimum health capacity. 26 | func (us UpgradeStrategy) SetMinimumHealthCapacity(cap float64) UpgradeStrategy { 27 | us.MinimumHealthCapacity = &cap 28 | return us 29 | } 30 | 31 | // SetMaximumOverCapacity sets the maximum over capacity. 32 | func (us UpgradeStrategy) SetMaximumOverCapacity(cap float64) UpgradeStrategy { 33 | us.MaximumOverCapacity = &cap 34 | return us 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/google/go-querystring/.gitignore: -------------------------------------------------------------------------------- 1 | *.test 2 | -------------------------------------------------------------------------------- /vendor/github.com/google/go-querystring/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Google. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/google/go-querystring/README.md: -------------------------------------------------------------------------------- 1 | # go-querystring # 2 | 3 | go-querystring is Go library for encoding structs into URL query parameters. 4 | 5 | 6 | **Documentation:** 7 | **Build Status:** [![Build Status](https://drone.io/github.com/google/go-querystring/status.png)](https://drone.io/github.com/google/go-querystring/latest) 8 | 9 | ## Usage ## 10 | 11 | ```go 12 | import "github.com/google/go-querystring/query" 13 | ``` 14 | 15 | go-querystring is designed to assist in scenarios where you want to construct a 16 | URL using a struct that represents the URL query parameters. You might do this 17 | to enforce the type safety of your parameters, for example, as is done in the 18 | [go-github][] library. 19 | 20 | The query package exports a single `Values()` function. A simple example: 21 | 22 | ```go 23 | type Options struct { 24 | Query string `url:"q"` 25 | ShowAll bool `url:"all"` 26 | Page int `url:"page"` 27 | } 28 | 29 | opt := Options{ "foo", true, 2 } 30 | v, _ := query.Values(opt) 31 | fmt.Print(v.Encode()) // will output: "q=foo&all=true&page=2" 32 | ``` 33 | 34 | [go-github]: https://github.com/google/go-github/commit/994f6f8405f052a117d2d0b500054341048fbb08 35 | 36 | ## License ## 37 | 38 | This library is distributed under the BSD-style license found in the [LICENSE](./LICENSE) 39 | file. 40 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.3 7 | - go: 1.4 8 | - go: 1.5 9 | - go: 1.6 10 | - go: tip 11 | 12 | install: 13 | - go get golang.org/x/tools/cmd/vet 14 | 15 | script: 16 | - go get -t -v ./... 17 | - diff -u <(echo -n) <(gofmt -d .) 18 | - go tool vet . 19 | - go test -v -race ./... 20 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.5 7 | - go: 1.6 8 | - go: 1.7 9 | - go: 1.8 10 | - go: 1.9 11 | - go: tip 12 | allow_failures: 13 | - go: tip 14 | 15 | install: 16 | - # Skip 17 | 18 | script: 19 | - go get -t -v ./... 20 | - diff -u <(echo -n) <(gofmt -d .) 21 | - go tool vet . 22 | - go test -v -race ./... 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package mux 6 | 7 | import ( 8 | "net/http" 9 | "net/http/httptest" 10 | "testing" 11 | ) 12 | 13 | func BenchmarkMux(b *testing.B) { 14 | router := new(Router) 15 | handler := func(w http.ResponseWriter, r *http.Request) {} 16 | router.HandleFunc("/v1/{v1}", handler) 17 | 18 | request, _ := http.NewRequest("GET", "/v1/anything", nil) 19 | for i := 0; i < b.N; i++ { 20 | router.ServeHTTP(nil, request) 21 | } 22 | } 23 | 24 | func BenchmarkMuxAlternativeInRegexp(b *testing.B) { 25 | router := new(Router) 26 | handler := func(w http.ResponseWriter, r *http.Request) {} 27 | router.HandleFunc("/v1/{v1:(?:a|b)}", handler) 28 | 29 | requestA, _ := http.NewRequest("GET", "/v1/a", nil) 30 | requestB, _ := http.NewRequest("GET", "/v1/b", nil) 31 | for i := 0; i < b.N; i++ { 32 | router.ServeHTTP(nil, requestA) 33 | router.ServeHTTP(nil, requestB) 34 | } 35 | } 36 | 37 | func BenchmarkManyPathVariables(b *testing.B) { 38 | router := new(Router) 39 | handler := func(w http.ResponseWriter, r *http.Request) {} 40 | router.HandleFunc("/v1/{v1}/{v2}/{v3}/{v4}/{v5}", handler) 41 | 42 | matchingRequest, _ := http.NewRequest("GET", "/v1/1/2/3/4/5", nil) 43 | notMatchingRequest, _ := http.NewRequest("GET", "/v1/1/2/3/4", nil) 44 | recorder := httptest.NewRecorder() 45 | for i := 0; i < b.N; i++ { 46 | router.ServeHTTP(nil, matchingRequest) 47 | router.ServeHTTP(recorder, notMatchingRequest) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_gorilla.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "net/http" 7 | 8 | "github.com/gorilla/context" 9 | ) 10 | 11 | func contextGet(r *http.Request, key interface{}) interface{} { 12 | return context.Get(r, key) 13 | } 14 | 15 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 16 | if val == nil { 17 | return r 18 | } 19 | 20 | context.Set(r, key, val) 21 | return r 22 | } 23 | 24 | func contextClear(r *http.Request) { 25 | context.Clear(r) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_gorilla_test.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "net/http" 7 | "testing" 8 | 9 | "github.com/gorilla/context" 10 | ) 11 | 12 | // Tests that the context is cleared or not cleared properly depending on 13 | // the configuration of the router 14 | func TestKeepContext(t *testing.T) { 15 | func1 := func(w http.ResponseWriter, r *http.Request) {} 16 | 17 | r := NewRouter() 18 | r.HandleFunc("/", func1).Name("func1") 19 | 20 | req, _ := http.NewRequest("GET", "http://localhost/", nil) 21 | context.Set(req, "t", 1) 22 | 23 | res := new(http.ResponseWriter) 24 | r.ServeHTTP(*res, req) 25 | 26 | if _, ok := context.GetOk(req, "t"); ok { 27 | t.Error("Context should have been cleared at end of request") 28 | } 29 | 30 | r.KeepContext = true 31 | 32 | req, _ = http.NewRequest("GET", "http://localhost/", nil) 33 | context.Set(req, "t", 1) 34 | 35 | r.ServeHTTP(*res, req) 36 | if _, ok := context.GetOk(req, "t"); !ok { 37 | t.Error("Context should NOT have been cleared at end of request") 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_native.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "context" 7 | "net/http" 8 | ) 9 | 10 | func contextGet(r *http.Request, key interface{}) interface{} { 11 | return r.Context().Value(key) 12 | } 13 | 14 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 15 | if val == nil { 16 | return r 17 | } 18 | 19 | return r.WithContext(context.WithValue(r.Context(), key, val)) 20 | } 21 | 22 | func contextClear(r *http.Request) { 23 | return 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context_native_test.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package mux 4 | 5 | import ( 6 | "context" 7 | "net/http" 8 | "testing" 9 | "time" 10 | ) 11 | 12 | func TestNativeContextMiddleware(t *testing.T) { 13 | withTimeout := func(h http.Handler) http.Handler { 14 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 15 | ctx, cancel := context.WithTimeout(r.Context(), time.Minute) 16 | defer cancel() 17 | h.ServeHTTP(w, r.WithContext(ctx)) 18 | }) 19 | } 20 | 21 | r := NewRouter() 22 | r.Handle("/path/{foo}", withTimeout(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 23 | vars := Vars(r) 24 | if vars["foo"] != "bar" { 25 | t.Fatal("Expected foo var to be set") 26 | } 27 | }))) 28 | 29 | rec := NewRecorder() 30 | req := newRequest("GET", "/path/bar") 31 | r.ServeHTTP(rec, req) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/.DEREK.yml: -------------------------------------------------------------------------------- 1 | maintainers: 2 | - alexellis 3 | - rgee0 4 | - ericstoekl 5 | - austinfrey 6 | 7 | features: 8 | - dco_check 9 | - comments 10 | 11 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Expected Behaviour 4 | 5 | 6 | 7 | ## Current Behaviour 8 | 9 | 10 | 11 | ## Possible Solution 12 | 13 | 14 | 15 | ## Steps to Reproduce (for bugs) 16 | 17 | 18 | 1. 19 | 2. 20 | 3. 21 | 4. 22 | 23 | ## Context 24 | 25 | 26 | 27 | ## Your Environment 28 | 29 | * Docker version `docker version` (e.g. Docker 17.0.05 ): 30 | 31 | * Are you using Docker Swarm or Kubernetes (FaaS-netes)? 32 | 33 | * Operating System and version (e.g. Linux, Windows, MacOS): 34 | 35 | * Link to your project or a code example to reproduce issue: 36 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 14 | .glide/ 15 | .idea 16 | 17 | faas-netes 18 | 19 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | language: go 4 | 5 | go: 6 | - 1.8.x 7 | 8 | install: 9 | - echo "Please don't go get" 10 | 11 | services: 12 | - docker 13 | 14 | before_script: 15 | - bash contrib/set_travis_experimental_mode.sh 16 | - curl -sSL get.docker.com | sudo -E sh 17 | 18 | after_success: 19 | - if [ ! -s "$TRAVIS_TAG" ] ; then 20 | docker tag $DOCKER_NS/faas-netesd:latest $DOCKER_NS/faas-netesd:$TRAVIS_TAG; 21 | docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD; 22 | docker push $DOCKER_NS/faas-netesd:$TRAVIS_TAG; 23 | fi 24 | 25 | script: 26 | - make build 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | ### License 4 | 5 | This project is licensed under the MIT License. 6 | 7 | ## Guidelines 8 | 9 | See guide for [FaaS](https://github.com/openfaas/faas/blob/master/CONTRIBUTING.md) here. 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.9.2 2 | 3 | RUN mkdir -p /go/src/github.com/openfaas/faas-netes/ 4 | 5 | WORKDIR /go/src/github.com/openfaas/faas-netes 6 | 7 | COPY vendor vendor 8 | COPY handlers handlers 9 | COPY types types 10 | COPY server.go . 11 | 12 | RUN curl -sL https://github.com/alexellis/license-check/releases/download/0.2.2/license-check > /usr/bin/license-check \ 13 | && chmod +x /usr/bin/license-check 14 | RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Project" 15 | RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") \ 16 | && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-netes . 17 | 18 | FROM alpine:3.6 19 | RUN apk --no-cache add ca-certificates 20 | WORKDIR /root/ 21 | 22 | EXPOSE 8080 23 | 24 | ENV http_proxy "" 25 | ENV https_proxy "" 26 | 27 | COPY --from=0 /go/src/github.com/openfaas/faas-netes/faas-netes . 28 | 29 | CMD ["./faas-netes"] 30 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/Dockerfile.arm64: -------------------------------------------------------------------------------- 1 | FROM alexellis2/golang:1.9-arm64 as build 2 | #FROM golang:1.7.5 3 | ENV GOPATH=/go/ 4 | RUN mkdir -p /go/src/github.com/openfaas/faas-netes/ 5 | 6 | WORKDIR /go/src/github.com/openfaas/faas-netes 7 | 8 | COPY vendor vendor 9 | COPY handlers handlers 10 | COPY types types 11 | COPY server.go . 12 | 13 | RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") \ 14 | && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-netes . 15 | 16 | FROM debian:stretch 17 | #FROM alpine:3.5 18 | #RUN apk --no-cache add ca-certificates 19 | RUN apt-get update -qy && apt-get -qy install ca-certificates 20 | WORKDIR /root/ 21 | 22 | EXPOSE 8080 23 | ENV http_proxy "" 24 | ENV https_proxy "" 25 | 26 | COPY --from=0 /go/src/github.com/openfaas/faas-netes/faas-netes . 27 | 28 | CMD ["./faas-netes"] 29 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/Dockerfile.armhf: -------------------------------------------------------------------------------- 1 | FROM alexellis2/go-armhf:1.7.4 2 | 3 | RUN mkdir -p /go/src/github.com/openfaas/faas-netes/ 4 | 5 | WORKDIR /go/src/github.com/openfaas/faas-netes 6 | 7 | COPY vendor vendor 8 | COPY handlers handlers 9 | COPY types types 10 | COPY server.go . 11 | 12 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-netes . 13 | 14 | FROM alpine:3.5 15 | RUN apk --no-cache add ca-certificates 16 | WORKDIR /root/ 17 | 18 | EXPOSE 8080 19 | ENV http_proxy "" 20 | ENV https_proxy "" 21 | 22 | COPY --from=0 /go/src/github.com/openfaas/faas-netes/faas-netes . 23 | 24 | CMD ["./faas-netes"] 25 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/Dockerfile.non-multi: -------------------------------------------------------------------------------- 1 | FROM golang:1.7.5 2 | 3 | RUN mkdir -p /go/src/github.com/openfaas/faas-netes/ 4 | 5 | WORKDIR /go/src/github.com/openfaas/faas-netes 6 | 7 | COPY vendor vendor 8 | COPY handlers handlers 9 | COPY types types 10 | COPY server.go . 11 | 12 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-netes . 13 | 14 | # FROM alpine:latest 15 | # WORKDIR /root/ 16 | 17 | EXPOSE 8080 18 | ENV http_proxy "" 19 | ENV https_proxy "" 20 | 21 | # COPY --from=0 /go/src/github.com/openfaas/faas-netes/faas-netes . 22 | 23 | CMD ["./faas-netes"] 24 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/MAINTAINERS: -------------------------------------------------------------------------------- 1 | alexellis 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/Makefile: -------------------------------------------------------------------------------- 1 | TAG?=latest 2 | SQUASH?=false 3 | 4 | local-fmt: 5 | gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") 6 | 7 | local-go: 8 | CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-netes 9 | 10 | local: local-fmt local-go 11 | 12 | build-arm64: 13 | docker build -t functions/faas-netesd:$(TAG)-arm64 . -f Dockerfile.arm64 14 | 15 | build-armhf: 16 | docker build -t functions/faas-netesd:$(TAG)-armhf . -f Dockerfile.armhf 17 | 18 | build-legacy: 19 | docker build --build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" -t functions/faas-netesd:$(TAG) . -f Dockerfile.non-multi --squash=${SQUASH} 20 | 21 | build: 22 | docker build --build-arg http_proxy="${http_proxy}" --build-arg https_proxy="${https_proxy}" -t functions/faas-netesd:$(TAG) . --squash=${SQUASH} 23 | 24 | push: 25 | docker push alexellis2/faas-netes:$(TAG) 26 | 27 | install: 28 | kubectl apply -f faas.yml,monitoring.yml,rbac.yml 29 | 30 | install-async: 31 | kubectl apply -f faas.async.yml,monitoring.yml,rbac.yml,nats.yml 32 | 33 | install-armhf: 34 | kubectl apply -f faas.armhf.yml,monitoring.armhf.yml,rbac.yml 35 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/QuickStart.md: -------------------------------------------------------------------------------- 1 | This file has moved to https://github.com/openfaas/faas/blob/master/guide/deployment_k8s.md 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/SECRETS.md: -------------------------------------------------------------------------------- 1 | ## Managing Secrets 2 | 3 | ### Create an image-pull secret: 4 | 5 | Set the following environmental variables: 6 | 7 | * $DOCKER_USERNAME 8 | * $DOCKER_PASSWORD 9 | * $DOCKER_EMAIL 10 | 11 | ``` 12 | $ kubectl create secret docker-registry dockerhub \ 13 | --docker-username=$DOCKER_USERNAME \ 14 | --docker-password=$DOCKER_PASSWORD \ 15 | --docker-email=$DOCKER_EMAIL 16 | ``` 17 | 18 | ### Deploy a function from a private Docker image 19 | 20 | ``` 21 | $ docker pull functions/alpine:latest 22 | $ docker tag functions/alpine:latest $DOCKER_USERNAME/private-alpine:latest 23 | $ docker push $DOCKER_USERNAME/private-alpine:latest 24 | ``` 25 | 26 | Now log into the Hub and make your image `private-alpine` private. 27 | 28 | ### Attempt to deploy the image 29 | 30 | You should see that the pod is not scheduled. 31 | 32 | ``` 33 | curl -X POST -d \ 34 | '{"image": "alexellis2/private-alpine:latest", "envProcess": "sha512sum", "service": "shametoo", "secrets": []}' $(minikube ip):31111/system/functions 35 | ``` 36 | 37 | ### Now invoke the faas-netes back-end directly 38 | 39 | Now update the function to use the new secret: 40 | 41 | 42 | ``` 43 | curl -X POST -d \ 44 | '{"image": "alexellis2/private-alpine:latest", "envProcess": "sha512sum", "service": "shametoo", "secrets": ["dockerhub"]}' $(minikube ip):31111/system/functions 45 | ``` 46 | 47 | You will now see that your function from a private registry has been deployed. 48 | 49 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | make build 4 | 5 | # os="$(uname -s)" 6 | 7 | # if [ "$os" = "Linux" ] ; then 8 | # cd openfaas 9 | # if ! [ -x "$(command -v helm)" ]; then 10 | # curl -SL https://storage.googleapis.com/kubernetes-helm/helm-v2.6.1-linux-amd64.tar.gz > /tmp/helm.tgz && \ 11 | # mkdir -p /tmp/helm/ && \ 12 | # tar -xvf helm.tgz --strip-components=1 -C /tmp/helm 13 | # /tmp/helm/helm lint 14 | # else 15 | # helm lint 16 | # fi 17 | # else 18 | # echo "Only checking helm lint on Linux" 19 | # fi 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/cloud/lb.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: gateway 5 | labels: 6 | app: gateway 7 | spec: 8 | ports: 9 | - port: 8080 10 | protocol: TCP 11 | targetPort: 8080 12 | nodePort: 31112 13 | selector: 14 | app: gateway 15 | type: LoadBalancer #LB 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/contrib/busybox.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: busybox 5 | namespace: default 6 | spec: 7 | containers: 8 | - image: busybox 9 | command: 10 | - sleep 11 | - "3600" 12 | imagePullPolicy: IfNotPresent 13 | name: busybox 14 | restartPolicy: Always 15 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/contrib/set_travis_experimental_mode.sh: -------------------------------------------------------------------------------- 1 | # Enable pre-release docker features in the travis build. 2 | # Can't be in .travis.yml as travis has trouble parsing the braces. 3 | echo "{\"experimental\": true}" | sudo tee /etc/docker/daemon.json 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/nats.armhf.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: nats 6 | labels: 7 | app: nats 8 | spec: 9 | type: NodePort 10 | ports: 11 | - port: 4222 12 | protocol: TCP 13 | targetPort: 4222 14 | nodePort: 31114 15 | selector: 16 | app: nats 17 | --- 18 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 19 | kind: Deployment 20 | metadata: 21 | name: nats 22 | spec: 23 | replicas: 1 24 | template: 25 | metadata: 26 | labels: 27 | app: nats 28 | spec: 29 | containers: 30 | - name: nats 31 | image: nats-streaming:0.6.0 32 | imagePullPolicy: Always 33 | ports: 34 | - containerPort: 4222 35 | protocol: TCP 36 | - containerPort: 8222 37 | protocol: TCP 38 | command: ["/nats-streaming-server"] 39 | args: 40 | - --store 41 | - memory 42 | - --cluster_id 43 | - faas-cluster 44 | 45 | 46 | --- 47 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 48 | kind: Deployment 49 | metadata: 50 | name: queue-worker 51 | spec: 52 | replicas: 1 53 | template: 54 | metadata: 55 | labels: 56 | app: queue-worker 57 | spec: 58 | containers: 59 | - name: queue-worker 60 | image: alexellis2/nats-queue-worker:0.1-armhf 61 | imagePullPolicy: Always 62 | 63 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/nats.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Service 4 | metadata: 5 | name: nats 6 | labels: 7 | app: nats 8 | spec: 9 | type: NodePort 10 | ports: 11 | - port: 4222 12 | protocol: TCP 13 | targetPort: 4222 14 | nodePort: 31114 15 | selector: 16 | app: nats 17 | --- 18 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 19 | kind: Deployment 20 | metadata: 21 | name: nats 22 | spec: 23 | replicas: 1 24 | template: 25 | metadata: 26 | labels: 27 | app: nats 28 | spec: 29 | containers: 30 | - name: nats 31 | image: nats-streaming:0.6.0 32 | imagePullPolicy: Always 33 | ports: 34 | - containerPort: 4222 35 | protocol: TCP 36 | - containerPort: 8222 37 | protocol: TCP 38 | command: ["/nats-streaming-server"] 39 | args: 40 | - --store 41 | - memory 42 | - --cluster_id 43 | - faas-cluster 44 | 45 | 46 | --- 47 | apiVersion: apps/v1beta1 # for versions before 1.6.0 use extensions/v1beta1 48 | kind: Deployment 49 | metadata: 50 | name: queue-worker 51 | spec: 52 | replicas: 1 53 | template: 54 | metadata: 55 | labels: 56 | app: queue-worker 57 | spec: 58 | containers: 59 | - name: queue-worker 60 | image: functions/queue-worker:0.4 61 | imagePullPolicy: Always 62 | env: 63 | - name: max_inflight 64 | value: "1" 65 | - name: ack_wait # Max duration of any async task / request 66 | value: "30s" 67 | 68 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/openfaas/Chart.yaml: -------------------------------------------------------------------------------- 1 | name: openfaas 2 | home: https://blog.alexellis.io/introducing-functions-as-a-service/ 3 | version: 1.0.0 4 | description: Enable Kubernetes as a backend for OpenFaaS (Functions as a Service) 5 | sources: 6 | - https://github.com/openfaas/faas 7 | - https://github.com/openfaas/faas-netes 8 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/openfaas/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "faas-netesd.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/openfaas/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.ingress.enabled -}} 2 | apiVersion: extensions/v1beta1 3 | kind: Ingress 4 | metadata: 5 | name: {{ template "faas-netesd.name" . }}-ingress 6 | labels: 7 | app: {{ template "faas-netesd.name" . }} 8 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} 9 | release: {{ .Release.Name }} 10 | heritage: {{ .Release.Service }} 11 | annotations: 12 | {{- range $key, $value := .Values.ingress.annotations }} 13 | {{ $key }}: {{ $value | quote }} 14 | {{- end }} 15 | spec: 16 | rules: 17 | {{- range $host := .Values.ingress.hosts }} 18 | - host: {{ $host.host }} 19 | http: 20 | paths: 21 | - path: {{ $host.path }} 22 | backend: 23 | serviceName: {{ $host.serviceName }} 24 | servicePort: {{ $host.servicePort }} 25 | {{- end -}} 26 | {{- if .Values.ingress.tls }} 27 | tls: 28 | {{ toYaml .Values.ingress.tls | indent 4 }} 29 | {{- end -}} 30 | {{- end -}} 31 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/openfaas/values.yaml: -------------------------------------------------------------------------------- 1 | functionNamespace: 2 | async: false 3 | armhf: false 4 | exposeServices: true 5 | serviceType: NodePort 6 | rbac: true 7 | 8 | # images 9 | images: 10 | controller: functions/faas-netesd:0.3.4 11 | controllerArmhf: functions/faas-netesd-armhf 12 | 13 | gateway: functions/gateway:0.6.13 14 | gatewayArmhf: functions/gateway:0.6.7-armhf 15 | 16 | prometheus: prom/prometheus:v1.5.2 17 | prometheusArmhf: alexellis2/prometheus-armhf:1.5.2 18 | 19 | alertmanager: prom/alertmanager:v0.7.1 20 | alertmanagerArmhf: alexellis2/alertmanager-armhf:0.5.1 21 | 22 | nats: nats-streaming:0.6.0 23 | natsArmhf: 24 | 25 | queueWorker: functions/queue-worker:0.4 26 | queueWorkerArmhf: 27 | 28 | # ingress configuration 29 | ingress: 30 | enabled: false 31 | # Used to create Ingress record (should be used with exposeServices: false). 32 | hosts: 33 | - host: faas-netesd.openfaas.local 34 | serviceName: faas-netesd 35 | servicePort: 8080 36 | path: / 37 | - host: gateway.openfaas.local 38 | serviceName: gateway 39 | servicePort: 8080 40 | path: / 41 | - host: prometheus.openfaas.local 42 | serviceName: prometheus 43 | servicePort: 9090 44 | path: / 45 | - host: alertmanager.openfaas.local 46 | serviceName: alertmanager 47 | servicePort: 9093 48 | path: / 49 | annotations: 50 | kubernetes.io/ingress.class: nginx 51 | tls: 52 | # Secrets must be manually created in the namespace. 53 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/rbac.yml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1beta1 2 | kind: ClusterRole 3 | metadata: 4 | name: faas-controller 5 | rules: 6 | - apiGroups: 7 | - "" 8 | resources: 9 | - services 10 | verbs: 11 | - get 12 | - list 13 | - watch 14 | - create 15 | - delete 16 | - update 17 | - apiGroups: 18 | - extensions 19 | resources: 20 | - deployments 21 | verbs: 22 | - get 23 | - list 24 | - watch 25 | - create 26 | - delete 27 | - update 28 | --- 29 | apiVersion: rbac.authorization.k8s.io/v1beta1 30 | kind: ClusterRoleBinding 31 | metadata: 32 | name: faas-controller 33 | roleRef: 34 | apiGroup: rbac.authorization.k8s.io 35 | kind: ClusterRole 36 | name: faas-controller 37 | subjects: 38 | - kind: ServiceAccount 39 | name: faas-controller 40 | namespace: default 41 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-netes/types/requests.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package types 5 | 6 | type ScaleServiceRequest struct { 7 | ServiceName string `json:"serviceName"` 8 | Replicas uint64 `json:"replicas"` 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 14 | .glide/ 15 | 16 | faas-backend 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.8.3 2 | 3 | RUN mkdir -p /go/src/github.com/openfaas/faas-provider/ 4 | 5 | WORKDIR /go/src/github.com/openfaas/faas-provider 6 | 7 | COPY vendor vendor 8 | COPY types types 9 | COPY serve.go . 10 | 11 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-provider . 12 | 13 | FROM alpine:3.5 14 | RUN apk --no-cache add ca-certificates 15 | WORKDIR /root/ 16 | 17 | EXPOSE 8080 18 | ENV http_proxy "" 19 | ENV https_proxy "" 20 | 21 | COPY --from=0 /go/src/github.com/openfaas/faas-provider/faas-provider . 22 | 23 | CMD ["./faas-provider] 24 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/README.md: -------------------------------------------------------------------------------- 1 | faas-provider 2 | ============== 3 | 4 | This is a common template or interface for you to start building your own OpenFaaS backend. 5 | 6 | Checkout the [backends guide here](https://github.com/openfaas/faas/blob/master/guide/backends.md) before starting. 7 | 8 | OpenFaaS projects use the MIT License and are written in Golang. We encourage the same for external / third-party providers. 9 | 10 | ### How to use this code 11 | 12 | We will setup all the standard HTTP routes for you, then start listening on a given TCP port - it should be 8080. 13 | 14 | Just implement the supplied routes. 15 | 16 | For an example checkout the [server.go](https://github.com/openfaas/faas-netes/blob/master/server.go) file in the [faas-netes](https://github.com/openfaas/faas-netes) Kubernetes backend. 17 | 18 | I.e.: 19 | 20 | ```golang 21 | bootstrapHandlers := bootTypes.FaaSHandlers{ 22 | FunctionProxy: handlers.MakeProxy(), 23 | DeleteHandler: handlers.MakeDeleteHandler(clientset), 24 | DeployHandler: handlers.MakeDeployHandler(clientset), 25 | FunctionReader: handlers.MakeFunctionReader(clientset), 26 | ReplicaReader: handlers.MakeReplicaReader(clientset), 27 | ReplicaUpdater: handlers.MakeReplicaUpdater(clientset), 28 | } 29 | var port int 30 | port = 8080 31 | bootstrapConfig := bootTypes.FaaSConfig{ 32 | ReadTimeout: time.Second * 8, 33 | WriteTimeout: time.Second * 8, 34 | TCPPort: &port, 35 | } 36 | 37 | bootstrap.Serve(&bootstrapHandlers, &bootstrapConfig) 38 | ``` 39 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/config.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "net/http" 5 | "time" 6 | ) 7 | 8 | // FaaSHandlers provide handlers for OpenFaaS 9 | type FaaSHandlers struct { 10 | FunctionReader http.HandlerFunc 11 | DeployHandler http.HandlerFunc 12 | DeleteHandler http.HandlerFunc 13 | ReplicaReader http.HandlerFunc 14 | FunctionProxy http.HandlerFunc 15 | ReplicaUpdater http.HandlerFunc 16 | 17 | // Optional: Update an existing function 18 | UpdateHandler http.HandlerFunc 19 | } 20 | 21 | // FaaSConfig set config for HTTP handlers 22 | type FaaSConfig struct { 23 | TCPPort *int 24 | ReadTimeout time.Duration 25 | WriteTimeout time.Duration 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/requests.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package types 5 | 6 | type ScaleServiceRequest struct { 7 | ServiceName string `json:"serviceName"` 8 | Replicas uint64 `json:"replicas"` 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/vendor.conf: -------------------------------------------------------------------------------- 1 | github.com/gorilla/mux 24fca303ac6da784b9e8269f724ddeb0b2eea5e7 2 | github.com/gorilla/context 08b5f424b9271eedf6f9f0ce86cb9396ed337a42 3 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/.DEREK.yml: -------------------------------------------------------------------------------- 1 | maintainers: 2 | - alexellis 3 | - rgee0 4 | - johnmccabe 5 | - jockdarock 6 | - ericstoekl 7 | - austinfrey 8 | - itscaro 9 | - rorpage 10 | - kenfdev 11 | 12 | features: 13 | - dco_check 14 | - comments 15 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Expected Behaviour 4 | 5 | 6 | 7 | ## Current Behaviour 8 | 9 | 10 | 11 | ## Possible Solution 12 | 13 | 14 | 15 | ## Steps to Reproduce (for bugs) 16 | 17 | 18 | 1. 19 | 2. 20 | 3. 21 | 4. 22 | 23 | ## Context 24 | 25 | 26 | 27 | ## Your Environment 28 | 29 | * Docker version `docker version` (e.g. Docker 17.0.05 ): 30 | 31 | * Are you using Docker Swarm or Kubernetes (FaaS-netes)? 32 | 33 | * Operating System and version (e.g. Linux, Windows, MacOS): 34 | 35 | * Link to your project or a code example to reproduce issue: 36 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/.gitignore: -------------------------------------------------------------------------------- 1 | fwatchdog 2 | fwatchdog-armhf 3 | **/node_modules/ 4 | **/*.DS_Store 5 | .vscode 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | services: 4 | - docker 5 | addons: 6 | apt: 7 | packages: 8 | - docker-ce 9 | 10 | before_install: 11 | 12 | script: 13 | - sh build.sh 14 | # Invoke ci script too 15 | - sh contrib/ci.sh 16 | after_success: 17 | - if [ ! -s "$TRAVIS_TAG" ] ; then 18 | docker tag $DOCKER_NS/gateway:latest-dev $DOCKER_NS/gateway:$TRAVIS_TAG; 19 | docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD; 20 | docker push $DOCKER_NS/gateway:$TRAVIS_TAG; 21 | fi 22 | deploy: 23 | provider: releases 24 | api_key: 25 | secure: "SVwbfJO008Z4TCcGPyjIPsOUcN+W9k8Pi4CFRFznskCd+qXbZd/so72ZdBSDUhR/s1U1+NrrVq43fW18aOI6YdPJgSOU1dJyR+EX5833U+B5yIosjEd0PiU9zcby8BB2k/RIEXgu/qWg7DzeZB50Jd8YOJqW5j8qX9qdl5GI09+8siGCUgoiXRquv/VC2Ucdh+V/+Twlm0ytC9IcvIuww5dhJQUsKGLfNRcykioG/RWnqNoJZ5afZ0s/FgOEO4fVmklMRQq5+07Jnub1HW308lvXiO7Utre4c8n8mOTjHxaNbroHggsdq/8KyPIHLukqc1t0iY7GdutangbY14YVcykZ3XcoCfT660Rtz/RfxEiVsrJ8rdjCLIKypw2wAKM1ZH+i6vdYVm+RAoMO83Qsxbfd+NFaS2UMSU+woPHWJ28oeeoPx0Vt3h2K+J6fWMVg5CBb7cN0TMcSFTZpJSgudnGj1k8P4hTms6Ey+gOolBqcJhwcrAvAVfpNcdiPPDkH2N7ME57Dolr80eAr09fpoaIffHFj71syItEAjBC60X30HzUsf+lyGh8gG9R2yAjMSLksrzSyvta6vWlVBNenxpIJdXi6E/JYCamQule4eNajjNU3Yeyzhy4OD4KTAXvadmvsmRaFS7HOS8kBMWEwLHUw61TyG2+1crveYqhJHOs=" 26 | file: 27 | - ./watchdog/fwatchdog 28 | - ./watchdog/fwatchdog-armhf 29 | - ./watchdog/fwatchdog-arm64 30 | - ./watchdog/fwatchdog.exe 31 | skip_cleanup: true 32 | on: 33 | tags: true 34 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/BACKERS.md: -------------------------------------------------------------------------------- 1 | ## Project backers 2 | 3 | This page shows the project's backers and sponsors. Thank you for your help 4 | 5 | View this page for live data [on Patreon for everyone who has pledged](https://www.patreon.com/alexellis). 6 | 7 | ### OpenFaaS Sponsors 8 | 9 | Become the first sponsor and have your logo on the [OpenFaaS homepage](https://www.openfaas.com/). 10 | 11 | ### Backers 12 | 13 | Listed by reward, followed by miscellaneous amounts. Names are (pending) until first pledge is taken by Patreon, this is at the start of each month. 14 | 15 | **Early Backers (reward)** 16 | 17 | * José Roberto Almaráz Da Cunha Júnior (pending) 18 | * Wesley Kennedy (pending) 19 | 20 | **OpenFaaS backers (reward)** 21 | 22 | * Eric Stoekl (pending) 23 | * Nic Jackson (pending) 24 | * Alex DeBrie (pending) 25 | * Johnny Mkhael (pending) 26 | * Finnian Anderson (pending) 27 | * Thom Toogood (pending) 28 | * Rafael Barbosa (pending) 29 | * Weston Steimel (pending) 30 | * Ram Gopinathan (pending) 31 | * Michael Herman (pending) 32 | 33 | **OpenFaaS patrons (reward)** 34 | 35 | **OpenFaaS fanclub (reward)** 36 | 37 | **Misc. amount** 38 | 39 | 1 person (pending) 40 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/CNAME: -------------------------------------------------------------------------------- 1 | docs.get-faas.com -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2017 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/MAINTAINERS: -------------------------------------------------------------------------------- 1 | alexellis 2 | rgee0 3 | johnmccabe 4 | jockdarock 5 | ericstoekl 6 | austinfrey 7 | itscaro 8 | rorpage 9 | kenfdev 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build 2 | 3 | build: 4 | ./build.sh 5 | build-gateway: 6 | (cd gateway; ./build.sh latest-dev) 7 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/api-docs/README.md: -------------------------------------------------------------------------------- 1 | ## Exploring or editing the Swagger API documentation 2 | 3 | The `swagger.yml` file can be viewed and edited in the Swagger UI. 4 | 5 | * Head over to the [Swagger editor](http://editor.swagger.io/) 6 | 7 | * Now click File -> Import URL 8 | 9 | * Type in `https://raw.githubusercontent.com/openfaas/faas/master/api-docs/swagger.yml` and click OK 10 | 11 | You can now view and edit the Swagger, copy back to your fork before pushing changes. 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: Visual Studio 2017 3 | 4 | install: 5 | - docker version 6 | 7 | build_script: 8 | - ps: .\watchdog\build.ps1 9 | 10 | artifacts: 11 | - path: watchdog\watchdog.exe 12 | name: watchdog 13 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -s "$TRAVIS_TAG" ] ; then 4 | echo "This build will be published under the tag: ${TRAVIS_TAG}" 5 | fi 6 | 7 | (cd gateway && ./build.sh) 8 | (cd watchdog && ./build.sh) 9 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker swarm init --advertise-addr=127.0.0.1 4 | 5 | ./deploy_stack.sh 6 | 7 | cd .. 8 | 9 | echo $GOPATH 10 | 11 | mkdir -p $GOPATH/src/github.com/openfaas/ 12 | cp -r faas $GOPATH/src/github.com/openfaas/ 13 | 14 | git clone https://github.com/openfaas/certify-incubator 15 | 16 | cp -r certify-incubator $GOPATH/src/github.com/openfaas/ 17 | 18 | cd $GOPATH/src/github.com/openfaas/faas/gateway/tests/integration && \ 19 | go test -v 20 | 21 | cd $GOPATH/src/github.com/openfaas/certify-incubator && \ 22 | make test 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/dind/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker:dind 2 | WORKDIR /root/ 3 | RUN apk --no-cache add git && \ 4 | git clone https://github.com/openfaas/faas 5 | WORKDIR /root/faas/ 6 | 7 | 8 | EXPOSE 8080 9 | EXPOSE 9090 10 | 11 | COPY entry.sh . 12 | RUN chmod +x ./entry.sh 13 | 14 | CMD ["./entry.sh"] 15 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/dind/entry.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | 3 | dockerd & 4 | 5 | while [ ! -e /var/run/docker.sock ] ; do sleep 0.25 && echo "Waiting for Docker socket" ; done 6 | 7 | docker swarm init 8 | 9 | ./deploy_stack.sh 10 | 11 | tail -f /dev/null 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/dind/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker rm -f faas 4 | docker run --name faas --privileged -p 8080:8080 -p 9090:9090 -d alexellis2/faas-dind:0.6.5 5 | 6 | ./test.sh 7 | 8 | echo "Quitting after 120 seconds." 9 | sleep 120 10 | 11 | docker rm -f faas 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/dind/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function test_gateway { 4 | for i in {1..100} 5 | do 6 | 7 | curl -s localhost:8080 |grep "angular" 8 | if [ ! 0 -eq $? ] 9 | then 10 | echo "Gateway not ready" 11 | sleep 5 12 | else 13 | break 14 | fi 15 | done 16 | 17 | echo 18 | 19 | } 20 | 21 | function test_function_output { 22 | for i in {1..100} 23 | do 24 | out=$(curl --fail -s localhost:8080/function/$1 -d "$2") 25 | echo $out 26 | if [ "$out" == "$3" ] 27 | then 28 | echo "Service $1 is ready" 29 | break 30 | else 31 | echo "Service $1 not ready" 32 | sleep 1 33 | fi 34 | done 35 | 36 | echo 37 | 38 | } 39 | 40 | 41 | function test_function { 42 | for i in {1..100} 43 | do 44 | curl -s --fail localhost:8080/function/$1 -d "$2" 45 | if [ ! 0 -eq $? ] 46 | then 47 | echo "Service $1 not ready" 48 | sleep 1 49 | else 50 | echo "Service $1 is ready" 51 | break 52 | fi 53 | done 54 | 55 | echo 56 | 57 | } 58 | 59 | function create_function { 60 | echo "Creating function: " $1 61 | curl -s --fail localhost:8080/system/functions -d "$1" 62 | } 63 | 64 | test_gateway 65 | 66 | test_function func_echoit hi 67 | test_function func_webhookstash hi 68 | test_function func_base64 hi 69 | test_function func_markdown "*salut*" 70 | 71 | create_function '{"service": "stronghash", "image": "functions/alpine", "envProcess": "sha512sum", "network": "func_functions"}' 72 | 73 | test_function_output stronghash "hi" "150a14ed5bea6cc731cf86c41566ac427a8db48ef1b9fd626664b3bfbb99071fa4c922f33dde38719b8c8354e2b7ab9d77e0e67fc12843920a712e73d558e197 -" 74 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/golang/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | 3 | RUN mkdir -p /usr/local/go 4 | ENV PATH=$PATH:/usr/local/go/bin 5 | RUN apt update && apt -qy install curl \ 6 | && curl -SL https://storage.googleapis.com/golang/go1.9.linux-arm64.tar.gz > go1.9.linux-arm64.tar.gz \ 7 | && tar -xvf go1.9.linux-arm64.tar.gz -C /usr/local/go --strip-components=1 8 | 9 | RUN go version 10 | 11 | CMD ["/bin/sh"] 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/nginx/.gitignore: -------------------------------------------------------------------------------- 1 | openfaas.htpasswd 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/nginx/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:latest 2 | 3 | COPY gateway.conf /etc/nginx/conf.d/default.conf 4 | 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/nginx/gateway.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8080; 3 | 4 | location /async-function/ { 5 | proxy_set_header X-Real-IP $remote_addr; 6 | proxy_set_header Host $http_host; 7 | proxy_pass http://gateway:8080/async-function/; 8 | } 9 | 10 | location /function/ { 11 | proxy_set_header X-Real-IP $remote_addr; 12 | proxy_set_header Host $http_host; 13 | proxy_pass http://gateway:8080/function/; 14 | } 15 | 16 | location / { 17 | proxy_set_header X-Real-IP $remote_addr; 18 | proxy_set_header Host $http_host; 19 | proxy_pass http://gateway:8080/; 20 | auth_basic "Restricted"; #For Basic Auth 21 | auth_basic_user_file /var/run/secrets/openfaas_htpasswd; #For Basic Auth 22 | } 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/contrib/prometheus/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM arm64v8/alpine:3.5 2 | 3 | workdir /root 4 | RUN apk add --update libarchive-tools 5 | 6 | ADD https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5.2.linux-arm64.tar.gz /root/ 7 | RUN bsdtar -xvf prometheus-*.tar.gz -C ./ --strip-components=1 8 | 9 | RUN mkdir -p /usr/share/prometheus 10 | RUN mkdir -p /etc/prometheus 11 | 12 | RUN cp prometheus /bin/prometheus 13 | RUN cp promtool /bin/promtool 14 | RUN cp prometheus.yml /etc/prometheus/prometheus.yml 15 | RUN cp -r console_libraries/ /usr/share/prometheus/console_libraries/ 16 | RUN cp -r consoles/ /usr/share/prometheus/consoles/ 17 | 18 | #RUN ln -s /usr/share/prometheus/console_libraries /usr/share/prometheus/consoles/ /etc/prometheus/ 19 | 20 | EXPOSE 9090 21 | VOLUME [ "/prometheus" ] 22 | WORKDIR /prometheus 23 | ENTRYPOINT [ "/bin/prometheus" ] 24 | CMD [ "-config.file=/etc/prometheus/prometheus.yml", \ 25 | "-storage.local.path=/prometheus", \ 26 | "-web.console.libraries=/usr/share/prometheus/console_libraries", \ 27 | "-web.console.templates=/usr/share/prometheus/consoles" ] 28 | 29 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/debug.md: -------------------------------------------------------------------------------- 1 | ### Debug information 2 | 3 | This is a useful Prometheus query to show: 4 | 5 | * Service replicas 6 | * Rate of invocation 7 | * Execution time of events 8 | 9 | http://localhost:9090/graph?g0.range_input=15m&g0.expr=gateway_service_count&g0.tab=0&g1.range_input=15m&g1.expr=rate(gateway_function_invocation_total%5B20s%5D)&g1.tab=0&g2.range_input=15m&g2.expr=gateway_functions_seconds_sum+%2F+gateway_functions_seconds_count&g2.tab=0 10 | 11 | 12 | ``` 13 | $ docker service ls -q |xargs -n 1 -I {} docker service scale {}=10;docker service scale func_gateway=1 ; 14 | $ docker service scale func_prometheus=1 ; docker service scale func_alertmanager=1 15 | ``` 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/deploy_extended.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! [ -x "$(command -v docker)" ]; then 4 | echo 'Unable to find docker command, please install Docker (https://www.docker.com/) and retry' >&2 5 | exit 1 6 | fi 7 | 8 | echo "Deploying extended stack" 9 | docker stack deploy func --compose-file docker-compose.extended.yml 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/deploy_stack.armhf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! [ -x "$(command -v docker)" ]; then 4 | echo 'Unable to find docker command, please install Docker (https://www.docker.com/) and retry' >&2 5 | exit 1 6 | fi 7 | 8 | echo "Deploying stack" 9 | docker stack deploy func --compose-file docker-compose.armhf.yml 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/deploy_stack.ps1: -------------------------------------------------------------------------------- 1 | #!ps1 2 | 3 | if (Get-Command docker -errorAction SilentlyContinue) 4 | { 5 | Write-Host "Deploying stack" 6 | docker stack deploy func --compose-file ./docker-compose.yml 7 | } 8 | else 9 | { 10 | Write-Host "Unable to find docker command, please install Docker (https://www.docker.com/) and retry" 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/deploy_stack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! [ -x "$(command -v docker)" ]; then 4 | echo 'Unable to find docker command, please install Docker (https://www.docker.com/) and retry' >&2 5 | exit 1 6 | fi 7 | 8 | echo "Deploying stack" 9 | docker stack deploy func --compose-file docker-compose.yml 10 | 11 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/docker-compose.arm64.yml: -------------------------------------------------------------------------------- 1 | version: "3.2" 2 | services: 3 | gateway: 4 | volumes: 5 | - "/var/run/docker.sock:/var/run/docker.sock" 6 | ports: 7 | - 8080:8080 8 | image: functions/gateway:0.6.9-arm64 9 | networks: 10 | - functions 11 | environment: 12 | read_timeout: 10 # set both here, and on your functions 13 | write_timeout: 10 # set both here, and on your functions 14 | dnsrr: "true" # Temporarily use dnsrr in place of VIP while issue persists on PWD 15 | deploy: 16 | placement: 17 | constraints: 18 | - 'node.role == manager' 19 | - 'node.platform.os == linux' 20 | prometheus: 21 | image: alexellis2/prometheus:1.5.2-arm64 22 | command: "-config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000 --alertmanager.url=http://alertmanager:9093" 23 | ports: 24 | - 9090:9090 25 | environment: 26 | no_proxy: "gateway" 27 | networks: 28 | - functions 29 | deploy: 30 | placement: 31 | constraints: 32 | - 'node.role == manager' 33 | - 'node.platform.os == linux' 34 | 35 | networks: 36 | functions: 37 | driver: overlay 38 | # Docker does not support this option yet - maybe create outside of the stack and reference as "external"? 39 | #attachable: true 40 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/docs/CNAME: -------------------------------------------------------------------------------- 1 | docs.get-faas.com -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/.gitignore: -------------------------------------------------------------------------------- 1 | gateway 2 | sample.txt 3 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.8.5 as build 2 | WORKDIR /go/src/github.com/openfaas/faas/gateway 3 | 4 | RUN curl -sL https://github.com/alexellis/license-check/releases/download/0.1/license-check > /usr/bin/license-check && chmod +x /usr/bin/license-check 5 | 6 | COPY vendor vendor 7 | 8 | COPY handlers handlers 9 | COPY metrics metrics 10 | COPY requests requests 11 | COPY tests tests 12 | 13 | COPY types types 14 | COPY queue queue 15 | COPY plugin plugin 16 | COPY server.go . 17 | 18 | # Run a gofmt and exclude all vendored code. 19 | RUN license-check -path ./ --verbose=false \ 20 | && test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" \ 21 | && go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover \ 22 | && CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway . 23 | 24 | FROM alpine:3.6 25 | WORKDIR /root/ 26 | 27 | EXPOSE 8080 28 | ENV http_proxy "" 29 | ENV https_proxy "" 30 | 31 | COPY --from=build /go/src/github.com/openfaas/faas/gateway/gateway . 32 | 33 | COPY assets assets 34 | 35 | CMD ["./gateway"] 36 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/Dockerfile.arm64: -------------------------------------------------------------------------------- 1 | FROM alexellis2/golang:1.9-arm64 as build 2 | WORKDIR /go/src/github.com/openfaas/faas/gateway 3 | ENV GOPATH=/go 4 | 5 | COPY vendor vendor 6 | 7 | COPY handlers handlers 8 | COPY metrics metrics 9 | COPY requests requests 10 | COPY tests tests 11 | 12 | COPY types types 13 | COPY queue queue 14 | COPY plugin plugin 15 | COPY server.go . 16 | 17 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway . 18 | 19 | FROM debian:stretch 20 | WORKDIR /root/ 21 | 22 | EXPOSE 8080 23 | ENV http_proxy "" 24 | ENV https_proxy "" 25 | 26 | COPY --from=build /go/src/github.com/openfaas/faas/gateway/gateway . 27 | 28 | COPY assets assets 29 | 30 | CMD ["./gateway"] 31 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/Dockerfile.armhf: -------------------------------------------------------------------------------- 1 | FROM alexellis2/go-armhf:1.7.4 2 | 3 | WORKDIR /go/src/github.com/openfaas/faas/gateway 4 | 5 | COPY vendor vendor 6 | 7 | COPY handlers handlers 8 | COPY metrics metrics 9 | COPY requests requests 10 | COPY tests tests 11 | COPY server.go . 12 | COPY types types 13 | COPY plugin plugin 14 | COPY queue queue 15 | 16 | RUN GOARM=6 CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gateway . 17 | 18 | FROM alpine:3.6 19 | WORKDIR /root/ 20 | 21 | EXPOSE 8080 22 | ENV http_proxy "" 23 | ENV https_proxy "" 24 | 25 | COPY --from=0 /go/src/github.com/openfaas/faas/gateway/gateway . 26 | 27 | COPY assets assets 28 | 29 | CMD ["./gateway"] 30 | 31 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/README.md: -------------------------------------------------------------------------------- 1 | # Gateway 2 | 3 | The API Gateway provides an external route into your functions and collects Cloud Native metrics through Prometheus, as well as a UI for creating and invoking functions. 4 | The gateway will scale functions according to demand by altering the service replica count in the Docker Swarm or Kubernetes API. 5 | 6 | Swagger docs: https://github.com/openfaas/faas/tree/master/api-docs 7 | 8 | **Environmental overrides:** 9 | The gateway can be configured through the following environment variables: 10 | 11 | | Option | Usage | 12 | |------------------------|--------------| 13 | | `write_timeout` | HTTP timeout for writing a response body from your function (in seconds). Default: `8` | 14 | | `read_timeout` | HTTP timeout for reading the payload from the client caller (in seconds). Default: `8` | 15 | | `functions_provider_url` | URL of an alternate microservice to manage functions (e.g., Kubernetes). When given, this overrides the default Docker Swarm provider. | 16 | | `faas_nats_address` | Address of NATS service. Required for asynchronous mode. | 17 | | `faas_nats_port` | Port for NATS service. Requrired for asynchronous mode. | 18 | | `faas_prometheus_host` | Host to connect to Prometheus. Default: `"prometheus"`. | 19 | | `faas_promethus_port` | Port to connect to Prometheus. Default: `9090`. | 20 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/android-chrome-192x192.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/android-chrome-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/android-chrome-256x256.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/apple-touch-icon.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/favicon-16x16.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/favicon-32x32.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/favicon.ico -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/icon.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/img/icons/ic_arrow_back_white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/img/icons/ic_close_24px.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/img/icons/ic_delete_black.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/img/icons/ic_info_outline_black_24px.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/img/icons/ic_menu_white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/img/icons/ic_search_black_24px.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/img/icons/ic_shop_two_black_24px.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "icons": [ 4 | { 5 | "src": "android-chrome-192x192.png", 6 | "sizes": "192x192", 7 | "type": "image/png" 8 | }, 9 | { 10 | "src": "android-chrome-256x256.png", 11 | "sizes": "256x256", 12 | "type": "image/png" 13 | } 14 | ], 15 | "theme_color": "#ffffff", 16 | "background_color": "#ffffff", 17 | "display": "standalone" 18 | } -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/gateway/assets/mstile-150x150.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/style/bootstrap.css: -------------------------------------------------------------------------------- 1 | /*Taken from PWD, remove styles not used.*/ 2 | 3 | .selected button { 4 | background-color: rgba(158,158,158,0.2); 5 | } 6 | 7 | md-card-content.terminal-container { 8 | background-color: #000; 9 | padding: 0; 10 | } 11 | 12 | .clock { 13 | font-family: 'Rationale', sans-serif; 14 | font-size: 3.0em; 15 | color: #1da4eb; 16 | text-align: center; 17 | } 18 | 19 | .welcome { 20 | background-color: #e7e7e7; 21 | } 22 | 23 | .welcome > div { 24 | text-align: center; 25 | } 26 | 27 | .welcome > div > img { 28 | max-width: 100%; 29 | } 30 | 31 | .g-recaptcha div { 32 | margin-left: auto; 33 | margin-right: auto; 34 | margin-bottom: auto; 35 | margin-top: 50px; 36 | } 37 | 38 | .disconnected { 39 | background-color: #FDF4B6; 40 | } 41 | md-input-container { 42 | margin-bottom: 0; 43 | } 44 | md-input-container .md-errors-spacer { 45 | height: 0; 46 | min-height: 0; 47 | } 48 | 49 | .monospace { 50 | font-family: 'Roboto Mono', monospace; 51 | } 52 | 53 | .validation-error { 54 | color: red; 55 | height: 52px; 56 | } 57 | 58 | .primary-item .md-list-item-inner{ 59 | color: rgb(63,81,181); 60 | font-weight: 500; 61 | } 62 | 63 | span.md-avatar { 64 | font-weight: bold; 65 | line-height: 40px; 66 | text-align: center; 67 | background-color: #1398D6; 68 | color: white; 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/assets/templates/funcstore.html: -------------------------------------------------------------------------------- 1 |
2 |

{{ $ctrl.message }}

3 |
4 |
5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 | 16 | {{func.name}} 17 | {{func.title | limitTo:1}} 18 |
19 |

{{ func.title }}

20 |

{{ func.description }}

21 |
22 | 23 |
24 |
25 |
-------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export dockerfile="Dockerfile" 4 | export arch=$(uname -m) 5 | 6 | export eTAG="latest-dev" 7 | 8 | if [ "$arch" = "armv7l" ] ; then 9 | dockerfile="Dockerfile.armhf" 10 | eTAG="latest-armhf-dev" 11 | fi 12 | 13 | echo "$1" 14 | if [ "$1" ] ; then 15 | eTAG=$1 16 | fi 17 | 18 | echo Building functions/gateway:$eTAG 19 | 20 | docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \ 21 | -t functions/gateway:$eTAG . -f $dockerfile --no-cache 22 | 23 | 24 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/handlers/asyncreport.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package handlers 5 | 6 | import ( 7 | "encoding/json" 8 | "io/ioutil" 9 | "net/http" 10 | "time" 11 | 12 | "github.com/openfaas/faas/gateway/metrics" 13 | "github.com/openfaas/faas/gateway/requests" 14 | ) 15 | 16 | // MakeAsyncReport makes a handler for asynchronous invocations to report back into. 17 | func MakeAsyncReport(metrics metrics.MetricOptions) http.HandlerFunc { 18 | return func(w http.ResponseWriter, r *http.Request) { 19 | defer r.Body.Close() 20 | 21 | report := requests.AsyncReport{} 22 | bytesOut, _ := ioutil.ReadAll(r.Body) 23 | json.Unmarshal(bytesOut, &report) 24 | 25 | trackInvocation(report.FunctionName, metrics, report.StatusCode) 26 | 27 | var taken time.Duration 28 | taken = time.Duration(report.TimeTaken) 29 | trackTimeExact(taken, metrics, report.FunctionName) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/handlers/cors.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import "net/http" 4 | 5 | type CorsHandler struct { 6 | Upstream *http.Handler 7 | AllowedHost string 8 | } 9 | 10 | func (c CorsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { 11 | // https://raw.githubusercontent.com/openfaas/store/master/store.json 12 | w.Header().Set("Access-Control-Allow-Headers", "Content-Type") 13 | w.Header().Set("Access-Control-Allow-Methods", "GET") 14 | w.Header().Set("Access-Control-Allow-Origin", c.AllowedHost) 15 | 16 | (*c.Upstream).ServeHTTP(w, r) 17 | } 18 | 19 | func DecorateWithCORS(upstream http.Handler, allowedHost string) http.Handler { 20 | return CorsHandler{ 21 | Upstream: &upstream, 22 | AllowedHost: allowedHost, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/handlers/forwarding_proxy.go: -------------------------------------------------------------------------------- 1 | package handlers 2 | 3 | import ( 4 | "log" 5 | "net/http" 6 | "net/http/httputil" 7 | "strconv" 8 | "strings" 9 | "time" 10 | 11 | "github.com/openfaas/faas/gateway/metrics" 12 | "github.com/openfaas/faas/gateway/types" 13 | "github.com/prometheus/client_golang/prometheus" 14 | ) 15 | 16 | // MakeForwardingProxyHandler create a handler which forwards HTTP requests 17 | func MakeForwardingProxyHandler(proxy *httputil.ReverseProxy, metrics *metrics.MetricOptions) http.HandlerFunc { 18 | return func(w http.ResponseWriter, r *http.Request) { 19 | uri := r.URL.String() 20 | 21 | log.Printf("> Forwarding [%s] to %s", r.Method, r.URL.String()) 22 | start := time.Now() 23 | 24 | writeAdapter := types.NewWriteAdapter(w) 25 | proxy.ServeHTTP(writeAdapter, r) 26 | 27 | seconds := time.Since(start).Seconds() 28 | log.Printf("< [%s] - %d took %f seconds\n", r.URL.String(), writeAdapter.GetHeaderCode(), seconds) 29 | 30 | forward := "/function/" 31 | if startsWith(uri, forward) { 32 | log.Printf("function=%s", uri[len(forward):]) 33 | 34 | service := uri[len(forward):] 35 | 36 | metrics.GatewayFunctionsHistogram. 37 | WithLabelValues(service). 38 | Observe(seconds) 39 | 40 | code := strconv.Itoa(writeAdapter.GetHeaderCode()) 41 | 42 | metrics.GatewayFunctionInvocation.With(prometheus.Labels{"function_name": service, "code": code}).Inc() 43 | } 44 | } 45 | } 46 | 47 | func startsWith(value, token string) bool { 48 | return len(value) > len(token) && strings.Index(value, token) == 0 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/metrics/swarmwatcher.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package metrics 5 | 6 | import ( 7 | "context" 8 | "fmt" 9 | "time" 10 | 11 | "github.com/docker/docker/api/types" 12 | "github.com/docker/docker/api/types/filters" 13 | "github.com/docker/docker/client" 14 | ) 15 | 16 | // AttachSwarmWatcher adds a go-route to monitor the amount of service replicas in the swarm 17 | // matching a 'function' label. 18 | func AttachSwarmWatcher(dockerClient *client.Client, metricsOptions MetricOptions, label string) { 19 | ticker := time.NewTicker(1 * time.Second) 20 | quit := make(chan struct{}) 21 | 22 | go func() { 23 | for { 24 | select { 25 | case <-ticker.C: 26 | serviceFilter := filters.NewArgs() 27 | 28 | options := types.ServiceListOptions{ 29 | Filters: serviceFilter, 30 | } 31 | 32 | services, err := dockerClient.ServiceList(context.Background(), options) 33 | if err != nil { 34 | fmt.Println(err) 35 | } 36 | 37 | for _, service := range services { 38 | if len(service.Spec.TaskTemplate.ContainerSpec.Labels[label]) > 0 { 39 | metricsOptions.ServiceReplicasCounter. 40 | WithLabelValues(service.Spec.Name). 41 | Set(float64(*service.Spec.Mode.Replicated.Replicas)) 42 | } 43 | } 44 | break 45 | case <-quit: 46 | return 47 | } 48 | } 49 | }() 50 | 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/queue/types.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package queue 5 | 6 | import "net/url" 7 | import "net/http" 8 | 9 | // Request for asynchronous processing 10 | type Request struct { 11 | Header http.Header 12 | Body []byte 13 | Method string 14 | QueryString string 15 | Function string 16 | CallbackURL *url.URL `json:"CallbackUrl"` 17 | } 18 | 19 | // CanQueueRequests can take on asynchronous requests 20 | type CanQueueRequests interface { 21 | Queue(req *Request) error 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/requests/forward_request.go: -------------------------------------------------------------------------------- 1 | package requests 2 | 3 | import "fmt" 4 | import "net/url" 5 | 6 | // ForwardRequest for proxying incoming requests 7 | type ForwardRequest struct { 8 | RawPath string 9 | RawQuery string 10 | Method string 11 | } 12 | 13 | // NewForwardRequest create a ForwardRequest 14 | func NewForwardRequest(method string, url url.URL) ForwardRequest { 15 | return ForwardRequest{ 16 | Method: method, 17 | RawQuery: url.RawQuery, 18 | RawPath: url.Path, 19 | } 20 | } 21 | 22 | // ToURL create formatted URL 23 | func (f *ForwardRequest) ToURL(addr string, watchdogPort int) string { 24 | if len(f.RawQuery) > 0 { 25 | return fmt.Sprintf("http://%s:%d%s?%s", addr, watchdogPort, f.RawPath, f.RawQuery) 26 | } 27 | return fmt.Sprintf("http://%s:%d%s", addr, watchdogPort, f.RawPath) 28 | 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/requests/prometheus.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package requests 5 | 6 | // PrometheusInnerAlertLabel PrometheusInnerAlertLabel 7 | type PrometheusInnerAlertLabel struct { 8 | AlertName string `json:"alertname"` 9 | FunctionName string `json:"function_name"` 10 | } 11 | 12 | // PrometheusInnerAlert PrometheusInnerAlert 13 | type PrometheusInnerAlert struct { 14 | Status string `json:"status"` 15 | Labels PrometheusInnerAlertLabel `json:"labels"` 16 | } 17 | 18 | // PrometheusAlert as produced by AlertManager 19 | type PrometheusAlert struct { 20 | Status string `json:"status"` 21 | Receiver string `json:"receiver"` 22 | Alerts []PrometheusInnerAlert `json:"alerts"` 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/tests/alerthandler_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package tests 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/openfaas/faas/gateway/handlers" 10 | ) 11 | 12 | func TestScale1to5(t *testing.T) { 13 | newReplicas := handlers.CalculateReplicas("firing", 1, 20) 14 | if newReplicas != 5 { 15 | t.Log("Expected increment in blocks of 5 from 1 to 5") 16 | t.Fail() 17 | } 18 | } 19 | 20 | func TestScale5to10(t *testing.T) { 21 | newReplicas := handlers.CalculateReplicas("firing", 5, 20) 22 | if newReplicas != 10 { 23 | t.Log("Expected increment in blocks of 5 from 5 to 10") 24 | t.Fail() 25 | } 26 | } 27 | 28 | func TestScaleCeilingOf20Replicas_Noaction(t *testing.T) { 29 | newReplicas := handlers.CalculateReplicas("firing", 20, 20) 30 | if newReplicas != 20 { 31 | t.Log("Expected ceiling of 20 replicas") 32 | t.Fail() 33 | } 34 | } 35 | 36 | func TestScaleCeilingOf20Replicas(t *testing.T) { 37 | newReplicas := handlers.CalculateReplicas("firing", 19, 20) 38 | if newReplicas != 20 { 39 | t.Log("Expected ceiling of 20 replicas") 40 | t.Fail() 41 | } 42 | } 43 | 44 | func TestBackingOff10to1(t *testing.T) { 45 | newReplicas := handlers.CalculateReplicas("resolved", 10, 20) 46 | if newReplicas != 1 { 47 | t.Log("Expected backing off to 1 replica") 48 | t.Fail() 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/tests/alexhostname_request.json: -------------------------------------------------------------------------------- 1 | { 2 | "session": { 3 | "sessionId": "SessionId.ea96e58d-dc16-43e1-b238-daac4541110c", 4 | "application": { 5 | "applicationId": "amzn1.ask.skill.72fb1025-aacc-4d05-a582-21344940c023" 6 | }, 7 | "attributes": {}, 8 | "user": { 9 | "userId": "amzn1.ask.account.AEN7KA5DBXAAWQPDUXTXFWBARZ5YZ6TNOQR5CUMV5LCCJTMBZVFP45SZVLGDD5GQBOM7QMELRS7LHG3F2FN2QQQMTBURDL5I4PQ33EHMNNGO4TXWG732Y6SDM2YZKHSPWIIWBH3GSE3Q3TTFAYN2Y66RHBKRANYCNMX2WORMASUGVRHUNBB4HZMJEC7HQDWUSXAOMP77WGJU4AY" 10 | }, 11 | "new": true 12 | }, 13 | "request": { 14 | "type": "IntentRequest", 15 | "requestId": "EdwRequestId.a934104e-3282-4620-b056-4aa4c5995503", 16 | "locale": "en-GB", 17 | "timestamp": "2016-12-07T15:50:01Z", 18 | "intent": { 19 | "name": "HostnameIntent", 20 | "slots": {} 21 | } 22 | }, 23 | "version": "1.0" 24 | } -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/tests/integration/README.md: -------------------------------------------------------------------------------- 1 | # Integration testing 2 | 3 | These tests should be run against the sample stack included in the repository root. 4 | 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/tests/integration/deletefunction_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package inttests 5 | 6 | import ( 7 | "net/http" 8 | "testing" 9 | ) 10 | 11 | func TestDelete_EmptyFunctionGivenFails(t *testing.T) { 12 | reqBody := `{"functionName":""}` 13 | _, code, err := fireRequest("http://localhost:8080/system/functions", http.MethodDelete, reqBody) 14 | 15 | if err != nil { 16 | t.Log(err) 17 | t.Fail() 18 | } 19 | 20 | if code != http.StatusBadRequest { 21 | t.Errorf("Got HTTP code: %d, want %d\n", code, http.StatusBadRequest) 22 | } 23 | } 24 | 25 | func TestDelete_NonExistingFunctionGives404(t *testing.T) { 26 | reqBody := `{"functionName":"does_not_exist"}` 27 | _, code, err := fireRequest("http://localhost:8080/system/functions", http.MethodDelete, reqBody) 28 | 29 | if err != nil { 30 | t.Log(err) 31 | t.Fail() 32 | } 33 | 34 | if code != http.StatusNotFound { 35 | t.Errorf("Got HTTP code: %d, want %d\n", code, http.StatusNotFound) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/tests/proxy_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "net/http" 5 | "testing" 6 | 7 | "github.com/openfaas/faas/gateway/handlers" 8 | ) 9 | 10 | func Test_GetContentType_UsesResponseValue(t *testing.T) { 11 | request := http.Header{} 12 | request.Add("Content-Type", "text/plain") 13 | response := http.Header{} 14 | response.Add("Content-Type", "text/html") 15 | 16 | contentType := handlers.GetContentType(request, response, "default") 17 | if contentType != response.Get("Content-Type") { 18 | t.Errorf("Got: %s, want: %s", contentType, response.Get("Content-Type")) 19 | } 20 | } 21 | 22 | func Test_GetContentType_UsesRequest_WhenResponseEmpty(t *testing.T) { 23 | request := http.Header{} 24 | request.Add("Content-Type", "text/plain") 25 | response := http.Header{} 26 | response.Add("Content-Type", "") 27 | 28 | contentType := handlers.GetContentType(request, response, "default") 29 | if contentType != request.Get("Content-Type") { 30 | t.Errorf("Got: %s, want: %s", contentType, request.Get("Content-Type")) 31 | } 32 | 33 | } 34 | 35 | func Test_GetContentType_UsesDefaultWhenRequestResponseEmpty(t *testing.T) { 36 | request := http.Header{} 37 | request.Add("Content-Type", "") 38 | response := http.Header{} 39 | response.Add("Content-Type", "") 40 | 41 | contentType := handlers.GetContentType(request, response, "default") 42 | if contentType != "default" { 43 | t.Errorf("Got: %s, want: %s", contentType, "default") 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/tests/resources_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/openfaas/faas/gateway/handlers" 7 | ) 8 | 9 | func Test_ParseMemory(t *testing.T) { 10 | value := "512 m" 11 | 12 | val, err := handlers.ParseMemory(value) 13 | if err != nil { 14 | t.Error(err) 15 | } 16 | 17 | if val != 1024*1024*512 { 18 | t.Errorf("want: %d got: %d", 1024, val) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/tests/unmarshall_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package tests 5 | 6 | import ( 7 | "testing" 8 | 9 | "io/ioutil" 10 | 11 | "encoding/json" 12 | 13 | "github.com/openfaas/faas/gateway/requests" 14 | ) 15 | 16 | // TestUnmarshallAlert is an exploratory test from TDD'ing the struct to parse a Prometheus alert 17 | func TestUnmarshallAlert(t *testing.T) { 18 | file, _ := ioutil.ReadFile("./test_alert.json") 19 | 20 | var alert requests.PrometheusAlert 21 | err := json.Unmarshal(file, &alert) 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | if (len(alert.Status)) == 0 { 26 | t.Fatal("No status read") 27 | } 28 | if (len(alert.Receiver)) == 0 { 29 | t.Fatal("No status read") 30 | } 31 | if (len(alert.Alerts)) == 0 { 32 | t.Fatal("No alerts read") 33 | } 34 | if (len(alert.Alerts[0].Labels.AlertName)) == 0 { 35 | t.Fatal("No alerts name") 36 | } 37 | if (len(alert.Alerts[0].Labels.FunctionName)) == 0 { 38 | t.Fatal("No function name read") 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/gateway/types/http_adapter.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package types 5 | 6 | import ( 7 | "fmt" 8 | "net/http" 9 | ) 10 | 11 | // WriteAdapter adapts a ResponseWriter 12 | type WriteAdapter struct { 13 | Writer http.ResponseWriter 14 | HttpResult *HttpResult 15 | } 16 | type HttpResult struct { 17 | HeaderCode int 18 | } 19 | 20 | //NewWriteAdapter create a new NewWriteAdapter 21 | func NewWriteAdapter(w http.ResponseWriter) WriteAdapter { 22 | return WriteAdapter{Writer: w, HttpResult: &HttpResult{}} 23 | } 24 | 25 | //Header adapts Header 26 | func (w WriteAdapter) Header() http.Header { 27 | return w.Writer.Header() 28 | } 29 | 30 | // Write adapts Write 31 | func (w WriteAdapter) Write(data []byte) (int, error) { 32 | return w.Writer.Write(data) 33 | } 34 | 35 | // WriteHeader adapts WriteHeader 36 | func (w WriteAdapter) WriteHeader(i int) { 37 | w.Writer.WriteHeader(i) 38 | w.HttpResult.HeaderCode = i 39 | fmt.Println("GetHeaderCode before", w.HttpResult.HeaderCode) 40 | } 41 | 42 | // GetHeaderCode result from WriteHeader 43 | func (w *WriteAdapter) GetHeaderCode() int { 44 | return w.HttpResult.HeaderCode 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/Dockerfile.alertmanager: -------------------------------------------------------------------------------- 1 | FROM prom/alertmanager:v0.7.1 2 | 3 | COPY alertmanager.yml /alertmanager.yml 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/Dockerfile.alertmanager.k8s: -------------------------------------------------------------------------------- 1 | FROM prom/alertmanager:v0.7.1 2 | 3 | COPY k8s.alertmanager.yml /alertmanager.yml 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/Dockerfile.prometheus: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus:v1.5.2 2 | 3 | COPY prometheus.yml /etc/prometheus/prometheus.yml 4 | COPY alert.rules /etc/prometheus/alert.rules 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/Dockerfile.prometheus.k8s: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus:v1.5.2 2 | 3 | COPY k8s.prometheus.yml /etc/prometheus/prometheus.yml 4 | COPY k8s.alert.rules /etc/prometheus/alert.rules 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/alert.rules: -------------------------------------------------------------------------------- 1 | ALERT service_down 2 | IF up == 0 3 | 4 | ALERT APIHighInvocationRate 5 | IF sum ( rate(gateway_function_invocation_total{code="200"}[10s]) ) by (function_name) > 5 6 | FOR 5s 7 | LABELS { 8 | service = "gateway", 9 | severity = "major", 10 | value = "{{$value}}" 11 | } 12 | ANNOTATIONS { 13 | summary = "High invocation total on {{ $labels.instance }}", 14 | description = "High invocation total on {{ $labels.instance }}" 15 | } 16 | 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/k8s.alert.rules: -------------------------------------------------------------------------------- 1 | ALERT service_down 2 | IF up == 0 3 | 4 | ALERT APIHighInvocationRate 5 | IF sum ( rate(gateway_function_invocation_total{code="200"}[10s]) ) by (function_name) > 5 6 | FOR 5s 7 | LABELS { 8 | service = "gateway", 9 | severity = "major", 10 | value = "{{$value}}" 11 | } 12 | ANNOTATIONS { 13 | summary = "High invocation total on {{ $labels.instance }}", 14 | description = "High invocation total on {{ $labels.instance }}" 15 | } 16 | 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/k8s.prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # By default, scrape targets every 15 seconds. 4 | evaluation_interval: 15s # By default, scrape targets every 15 seconds. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | monitor: 'faas-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | - 'alert.rules' 15 | 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # Override the global default and scrape targets from this job every 5 seconds. 24 | scrape_interval: 5s 25 | 26 | # metrics_path defaults to '/metrics' 27 | # scheme defaults to 'http'. 28 | static_configs: 29 | - targets: ['localhost:9090'] 30 | 31 | - job_name: "gateway" 32 | scrape_interval: 5s 33 | dns_sd_configs: 34 | - names: ['gateway.default.svc.cluster.local'] 35 | port: 8080 36 | type: A 37 | refresh_interval: 5s 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/prometheus/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # By default, scrape targets every 15 seconds. 4 | evaluation_interval: 15s # By default, scrape targets every 15 seconds. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | monitor: 'faas-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | - 'alert.rules' 15 | 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # Override the global default and scrape targets from this job every 5 seconds. 24 | scrape_interval: 5s 25 | 26 | # metrics_path defaults to '/metrics' 27 | # scheme defaults to 'http'. 28 | static_configs: 29 | - targets: ['localhost:9090'] 30 | 31 | - job_name: "gateway" 32 | scrape_interval: 5s 33 | dns_sd_configs: 34 | - names: ['tasks.gateway'] 35 | port: 8080 36 | type: A 37 | refresh_interval: 5s 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/.gitignore: -------------------------------------------------------------------------------- 1 | master.zip 2 | build 3 | template 4 | .vscode 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/AlpineFunction/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin 4 | # COPY ./fwatchdog /usr/bin/ 5 | RUN chmod +x /usr/bin/fwatchdog 6 | 7 | # Populate example here 8 | # ENV fprocess="wc -l" 9 | 10 | HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1 11 | CMD ["fwatchdog"] 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/AlpineFunction/Dockerfile.arm64: -------------------------------------------------------------------------------- 1 | FROM arm64v8/alpine:3.6 2 | 3 | ADD https://github.com/alexellis/faas/releases/download/0.6.9/fwatchdog-arm64 /usr/bin/fwatchdog 4 | # COPY ./fwatchdog /usr/bin/ 5 | RUN chmod +x /usr/bin/fwatchdog 6 | 7 | # Populate example here 8 | # ENV fprocess="wc -l" 9 | 10 | HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1 11 | CMD ["fwatchdog"] 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/AlpineFunction/Dockerfile.armhf: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog-armhf /usr/bin/fwatchdog 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | # Populate example here 7 | # ENV fprocess="wc -l" 8 | HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1 9 | CMD ["fwatchdog"] 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/AlpineFunction/README.md: -------------------------------------------------------------------------------- 1 | ## AlpineFunction 2 | 3 | This is a base image for Alpine Linux which already has the watchdog added and configured with a healthcheck. 4 | 5 | This image is published on the Docker hub as `functions/alpine:latest`. 6 | 7 | In order to deploy it - make sure you specify an "fprocess" value at runtime i.e. `sha512sum` or `wc -l`. See the docker-compose.yml file for more details on usage. 8 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/AlpineFunction/build.armhf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -f Dockerfile.armhf -t functions/alpine:latest-armhf . 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ApiKeyProtected/.gitignore: -------------------------------------------------------------------------------- 1 | ApiKeyProtected 2 | 3 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ApiKeyProtected/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.9.2-alpine as builder 2 | 3 | MAINTAINER alex@openfaas.com 4 | ENTRYPOINT [] 5 | 6 | RUN apk --no-cache add make curl \ 7 | && curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog > /usr/bin/fwatchdog \ 8 | && chmod +x /usr/bin/fwatchdog 9 | 10 | WORKDIR /go/src/github.com/openfaas/faas/sample-functions/ApiKeyProtected 11 | 12 | COPY handler.go . 13 | # COPY vendor vendor 14 | 15 | RUN go install 16 | 17 | FROM alpine:3.6 18 | 19 | # Needed to reach the hub 20 | RUN apk --no-cache add ca-certificates 21 | 22 | COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog 23 | COPY --from=builder /go/bin/ApiKeyProtected /usr/bin/ApiKeyProtected 24 | ENV fprocess "/usr/bin/ApiKeyProtected" 25 | 26 | CMD ["/usr/bin/fwatchdog"] 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ApiKeyProtected/README.md: -------------------------------------------------------------------------------- 1 | ### Api-Key-Protected sample 2 | 3 | To use this sample provide an env variable for the container/service in `secret_api_key`. 4 | 5 | Then when calling via the gateway pass the additional header "X-Api-Key", if it matches the `secret_api_key` value then the function will give access, otherwise access denied. 6 | 7 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ApiKeyProtected/handler.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | "os" 9 | 10 | "github.com/openfaas/faas/watchdog/types" 11 | ) 12 | 13 | func handle(header http.Header, body []byte) { 14 | key := header.Get("X-Api-Key") 15 | if key == os.Getenv("secret_api_key") { 16 | fmt.Println("Unlocked the function!") 17 | } else { 18 | fmt.Println("Access denied!") 19 | } 20 | } 21 | 22 | func main() { 23 | bytes, _ := ioutil.ReadAll(os.Stdin) 24 | req, err := types.UnmarshalRequest(bytes) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | handle(req.Header, req.Body.Raw) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/R/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM artemklevtsov/r-alpine:latest 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.6.1/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | WORKDIR /root/ 7 | 8 | COPY handler.R . 9 | 10 | ENV fprocess="Rscript handler.R" 11 | 12 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 13 | 14 | CMD ["fwatchdog"] 15 | 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/R/README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "BaseFunction for R" 3 | output: github_document 4 | --- 5 | 6 | ```{r setup, include=FALSE} 7 | knitr::opts_chunk$set(echo = TRUE) 8 | ``` 9 | 10 | Use this FaaS function using R. 11 | 12 | **Deploy the base R function** 13 | 14 | (Make sure you have already deployed FaaS with ./deploy_stack.sh in the root of this Github repository. 15 | 16 | * Option 1 - click *Create a new function* on the FaaS UI 17 | 18 | * Option 2 - use the [faas-cli](https://github.com/openfaas/faas-cli/) (experimental) 19 | 20 | ``` 21 | # curl -sSL https://get.openfaas.com | sudo sh 22 | 23 | # faas-cli -action=deploy -image=functions/base:R-3.4.1-alpine -name=baser 24 | 200 OK 25 | URL: http://localhost:8080/function/baser 26 | ``` 27 | 28 | **Say Hi with input** 29 | 30 | `curl` is good to test function. 31 | 32 | ``` 33 | $ curl http://localhost:8080/function/baser -d "test" 34 | ``` 35 | 36 | **Customize the transformation** 37 | 38 | If you want to customise the transformation then edit the Dockerfile or the fprocess variable and create a new function. 39 | 40 | **Remove the function** 41 | 42 | You can remove the function with `docker service rm baser`. -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/R/README.md: -------------------------------------------------------------------------------- 1 | BaseFunction for R 2 | ================ 3 | 4 | Use this FaaS function using R. 5 | 6 | **Deploy the base R function** 7 | 8 | (Make sure you have already deployed FaaS with ./deploy\_stack.sh in the root of this Github repository. 9 | 10 | - Option 1 - click *Create a new function* on the FaaS UI 11 | 12 | - Option 2 - use the [faas-cli](https://github.com/openfaas/faas-cli/) (experimental) 13 | 14 | 15 | 16 | # curl -sSL https://get.openfaas.com | sudo sh 17 | 18 | # faas-cli -action=deploy -image=functions/base:R-3.4.1-alpine -name=baser 19 | 200 OK 20 | URL: http://localhost:8080/function/baser 21 | 22 | **Say Hi with input** 23 | 24 | `curl` is good to test function. 25 | 26 | $ curl http://localhost:8080/function/baser -d "test" 27 | 28 | **Customize the transformation** 29 | 30 | If you want to customise the transformation then edit the Dockerfile or the fprocess variable and create a new function. 31 | 32 | **Remove the function** 33 | 34 | You can remove the function with `docker service rm baser`. 35 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/R/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/base:R-3.4.1-alpine" 4 | docker build -t functions/base:R-3.4.1-alpine . 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/R/handler.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | 3 | f <- file("stdin") 4 | open(f) 5 | line<-readLines(f, n=1, warn = FALSE) 6 | 7 | write(paste0("Hi ", line), stderr()) 8 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/README.md: -------------------------------------------------------------------------------- 1 | ## Base function examples 2 | 3 | Examples of base functions are provided here. 4 | 5 | Each one will read the request from the watchdog then print it back resulting in an HTTP 200. 6 | 7 | | Language | Docker image | Notes | 8 | |------------------------|-----------------------------------------|----------------------------------------| 9 | | Node.js | functions/base:node-6.9.1-alpine | Node.js built on Alpine Linux | 10 | | Coffeescript | functions/base:node-6.9.1-alpine | Coffeescript/Nodejs built on Alpine Linux | 11 | | Golang | functions/base:golang-1.7.5-alpine | Golang compiled on Alpine Linux | 12 | | Python | functions/base:python-2.7-alpine | Python 2.7 built on Alpine Linux | 13 | | Java | functions/base:openjdk-8u121-jdk-alpine | OpenJDK built on Alpine Linux | 14 | | Dotnet Core | functions/base:dotnet-sdk | Microsoft dotnet core SDK | 15 | | Busybox / shell | functions/alpine:latest | Busybox contains useful binaries which can be turned into a FaaS function such as `sha512sum` or `cat` | 16 | | R | functions/base:R-3.4.1-alpine | R lang ready on Alpine Linux | 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/cobol/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM toricls/gnucobol:latest 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | WORKDIR /root/ 7 | 8 | COPY handler.cob . 9 | RUN cobc -x handler.cob 10 | ENV fprocess="./handler" 11 | 12 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 13 | 14 | CMD ["fwatchdog"] 15 | 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/cobol/README.md: -------------------------------------------------------------------------------- 1 | GNUCobol 2 | ========= 3 | 4 | Any binary can become a FaaS process, even Cobol through GNUCobol. 5 | 6 | Here's an example of deploying this base function to FaaS which reads from stdin (called SYSIN in Cobol) and prints it to the screen. 7 | 8 | ![https://pbs.twimg.com/media/C_AMvtcXcAAbnGk.jpg:large](https://pbs.twimg.com/media/C_AMvtcXcAAbnGk.jpg:large) 9 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/cobol/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/base:cobol" 4 | docker build -t functions/base:cobol . 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/cobol/handler.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. APP. 3 | *> Example based upon http://stackoverflow.com/q/938760/1420197 4 | *> More on COBOL @ https://www.ibm.com/support/knowledgecenter/en/SS6SG3_3.4.0/com.ibm.entcobol.doc_3.4/tpbeg15.htm 5 | ENVIRONMENT DIVISION. 6 | INPUT-OUTPUT SECTION. 7 | FILE-CONTROL. 8 | SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL. 9 | 10 | DATA DIVISION. 11 | FILE SECTION. 12 | FD SYSIN. 13 | 01 ln PIC X(64). 14 | 88 EOF VALUE HIGH-VALUES. 15 | 16 | WORKING-STORAGE SECTION. 17 | PROCEDURE DIVISION. 18 | 19 | DISPLAY "Request data: " 20 | DISPLAY "------------" 21 | 22 | OPEN INPUT SYSIN 23 | READ SYSIN 24 | AT END SET EOF TO TRUE 25 | END-READ 26 | PERFORM UNTIL EOF 27 | 28 | 29 | DISPLAY ln 30 | 31 | READ SYSIN 32 | AT END SET EOF TO TRUE 33 | END-READ 34 | END-PERFORM 35 | CLOSE SYSIN 36 | 37 | DISPLAY "------------" 38 | STOP RUN. 39 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/cobol/hello.cob: -------------------------------------------------------------------------------- 1 | IDENTIFICATION DIVISION. 2 | PROGRAM-ID. HELLO-WORLD. 3 | PROCEDURE DIVISION. 4 | DISPLAY 'FaaS running COBOL in a container!'. 5 | STOP RUN. 6 | 7 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/coffee/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:6.9.1-alpine 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | WORKDIR /root/ 7 | 8 | COPY package.json . 9 | 10 | RUN npm install -g coffee-script && \ 11 | npm i 12 | 13 | COPY handler.coffee . 14 | 15 | ENV fprocess="coffee handler.coffee" 16 | 17 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 18 | 19 | CMD ["fwatchdog"] 20 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/coffee/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/base:coffeescript-1.12-alpine" 4 | docker build -t functions/base:coffeescript-1.12-alpine . 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/coffee/handler.coffee: -------------------------------------------------------------------------------- 1 | getStdin = require 'get-stdin' 2 | 3 | handler = (req) -> console.log req 4 | 5 | getStdin() 6 | .then (val) -> handler val 7 | .catch (e) -> console.error e.stack 8 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/coffee/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NodejsBase", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "faas_index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "coffeescript": "^1.12.4", 14 | "get-stdin": "^5.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/dncore/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM microsoft/dotnet:sdk 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 7 | 8 | WORKDIR /root/ 9 | COPY src src 10 | WORKDIR /root/src 11 | RUN dotnet restore 12 | RUN dotnet build 13 | 14 | ENV fprocess="dotnet ./bin/Debug/netcoreapp1.1/root.dll" 15 | EXPOSE 8080 16 | CMD ["fwatchdog"] 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/dncore/src/.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | obj/ 3 | .nuget/ 4 | .dotnet/ 5 | .templateengine/ 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/dncore/src/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace root 5 | { 6 | class Program 7 | { 8 | private static string getStdin() { 9 | StringBuilder buffer = new StringBuilder(); 10 | string s; 11 | while ((s = Console.ReadLine()) != null) 12 | { 13 | buffer.AppendLine(s); 14 | } 15 | return buffer.ToString(); 16 | } 17 | 18 | static void Main(string[] args) 19 | { 20 | string buffer = getStdin(); 21 | 22 | Console.WriteLine(buffer); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/dncore/src/root.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp1.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/golang/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.7.5-alpine 2 | 3 | MAINTAINER alexellis2@gmail.com 4 | ENTRYPOINT [] 5 | 6 | WORKDIR /go/src/github.com/openfaas/faas/sample-functions/golang 7 | COPY . /go/src/github.com/openfaas/faas/sample-functions/golang 8 | 9 | RUN go install 10 | 11 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin 12 | RUN chmod +x /usr/bin/fwatchdog 13 | 14 | ENV fprocess "/go/bin/golang" 15 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 16 | 17 | CMD [ "/usr/bin/fwatchdog"] 18 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/golang/Dockerfile.win: -------------------------------------------------------------------------------- 1 | FROM golang:1.7.5-windowsservercore 2 | MAINTAINER alexellis2@gmail.com 3 | ENTRYPOINT [] 4 | 5 | WORKDIR /go/src/github.com/openfaas/faas/sample-functions/golang 6 | COPY . /go/src/github.com/openfaas/faas/sample-functions/golang 7 | RUN go build 8 | 9 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog.exe /watchdog.exe 10 | 11 | EXPOSE 8080 12 | ENV fprocess="golang.exe" 13 | 14 | ENV suppress_lock="true" 15 | 16 | CMD ["watchdog.exe"] 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/golang/README.md: -------------------------------------------------------------------------------- 1 | BaseFunction for Golang 2 | ========================= 3 | 4 | You will find a Dockerfile for Linux and one for Windows so that you can run serverless functions in a mixed-OS swarm. 5 | 6 | Dockerfile for Windows 7 | * [Dockerfile.win](https://github.com/openfaas/faas/blob/master/sample-functions/BaseFunctions/golang/Dockerfile.win) 8 | 9 | This function reads STDIN then prints it back - you can use it to create an "echo service" or as a basis to write your own function. 10 | 11 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/golang/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/base:golang-1.7.5-alpine" 4 | docker build -t functions/base:golang-1.7.5-alpine . 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/golang/handler.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "os" 8 | ) 9 | 10 | func main() { 11 | input, err := ioutil.ReadAll(os.Stdin) 12 | if err != nil { 13 | log.Fatalf("Unable to read standard input: %s", err.Error()) 14 | } 15 | fmt.Println(string(input)) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/java/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/java/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u121-jdk-alpine 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | WORKDIR /root/ 7 | 8 | COPY Handler.java . 9 | RUN javac Handler.java 10 | 11 | ENV fprocess="java Handler" 12 | 13 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 14 | 15 | CMD ["fwatchdog"] 16 | 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/java/Handler.java: -------------------------------------------------------------------------------- 1 | import java.io.BufferedReader; 2 | import java.io.IOException; 3 | import java.io.InputStreamReader; 4 | 5 | public class Handler { 6 | 7 | public static void main(String[] args) { 8 | try { 9 | 10 | String input = readStdin(); 11 | System.out.print(input); 12 | 13 | } catch(IOException e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | 18 | private static String readStdin() throws IOException { 19 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 20 | String input = ""; 21 | while(true) { 22 | String line = br.readLine(); 23 | if(line==null) { 24 | break; 25 | } 26 | input = input + line + "\n"; 27 | } 28 | return input; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/java/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/base:openjdk-8u121-jdk-alpine" 4 | docker build -t functions/base:openjdk-8u121-jdk-alpine . 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/node/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:6.9.1-alpine 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | WORKDIR /root/ 7 | 8 | COPY package.json . 9 | 10 | RUN npm i 11 | COPY handler.js . 12 | 13 | ENV fprocess="node handler.js" 14 | 15 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 16 | 17 | CMD ["fwatchdog"] 18 | 19 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/node/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/base:node-6.9.1-alpine" 4 | docker build -t functions/base:node-6.9.1-alpine . 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/node/handler.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | 3 | let getStdin = require('get-stdin'); 4 | 5 | let handle = (req) => { 6 | console.log(req); 7 | }; 8 | 9 | getStdin().then(val => { 10 | handle(val); 11 | }).catch(e => { 12 | console.error(e.stack); 13 | }); 14 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NodejsBase", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "faas_index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "get-stdin": "^5.0.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/python/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7-alpine 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | WORKDIR /root/ 7 | 8 | COPY handler.py . 9 | 10 | ENV fprocess="python handler.py" 11 | 12 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 13 | 14 | CMD ["fwatchdog"] 15 | 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/python/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/base:python-2.7-alpine" 4 | docker build -t functions/base:python-2.7-alpine . 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/BaseFunctions/python/handler.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | def get_stdin(): 4 | buf = "" 5 | for line in sys.stdin: 6 | buf = buf + line 7 | return buf 8 | 9 | if(__name__ == "__main__"): 10 | st = get_stdin() 11 | print(st) 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CHelloWorld/.gitignore: -------------------------------------------------------------------------------- 1 | template 2 | build 3 | master.zip 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CHelloWorld/README.md: -------------------------------------------------------------------------------- 1 | Hello World in C 2 | =================== 3 | 4 | This is hello world in C using GCC and Alpine Linux. 5 | 6 | It also makes use of a multi-stage build and a `scratch` container for the runtime. 7 | 8 | ``` 9 | $ faas-cli build -f ./stack.yml 10 | ``` 11 | 12 | If pushing to a remote registry change the name from `alexellis` to your own Hub account. 13 | 14 | ``` 15 | $ faas-cli push -f ./stack.yml 16 | $ faas-cli deploy -f ./stack.yml 17 | ``` 18 | 19 | Then invoke via `curl`, `faas-cli` or the UI. 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CHelloWorld/src/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 as builder 2 | RUN apk add --no-cache curl \ 3 | && curl -SL https://github.com/openfaas/faas/releases/download/0.6.4/fwatchdog > /usr/bin/fwatchdog \ 4 | && chmod +x /usr/bin/fwatchdog \ 5 | && apk --no-cache del curl 6 | 7 | WORKDIR /root/ 8 | 9 | RUN apk add --no-cache gcc \ 10 | musl-dev 11 | COPY main.c . 12 | 13 | RUN gcc main.c -static -o /main \ 14 | && chmod +x /main \ 15 | && /main 16 | 17 | FROM scratch 18 | 19 | COPY --from=builder /main / 20 | COPY --from=builder /usr/bin/fwatchdog / 21 | COPY --from=builder /tmp /tmp 22 | 23 | ENV fprocess="/main" 24 | 25 | CMD ["/fwatchdog"] 26 | 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CHelloWorld/src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | printf("Hello world\n"); 6 | 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CHelloWorld/stack.yml: -------------------------------------------------------------------------------- 1 | provider: 2 | name: faas 3 | gateway: http://localhost:8080 4 | 5 | functions: 6 | helloc: 7 | lang: Dockerfile 8 | handler: ./src 9 | image: alexellis/helloc 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | RUN apk --update add nodejs nodejs-npm 3 | 4 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin 5 | RUN chmod +x /usr/bin/fwatchdog 6 | 7 | COPY package.json . 8 | COPY handler.js . 9 | COPY parser.js . 10 | COPY sample.json . 11 | 12 | RUN npm i 13 | ENV fprocess="node handler.js" 14 | CMD ["fwatchdog"] 15 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/handler.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | let fs = require('fs'); 3 | let sample = require("./sample.json"); 4 | let cheerio = require('cheerio'); 5 | let Parser = require('./parser'); 6 | var request = require("request"); 7 | 8 | const getStdin = require('get-stdin'); 9 | 10 | getStdin().then(content => { 11 | let request = JSON.parse(content); 12 | handle(request, request.request.intent); 13 | }); 14 | 15 | function tellWithCard(speechOutput) { 16 | sample.response.outputSpeech.text = speechOutput 17 | sample.response.card.content = speechOutput 18 | sample.response.card.title = "Captains"; 19 | console.log(JSON.stringify(sample)); 20 | process.exit(0); 21 | } 22 | 23 | function handle(request, intent) { 24 | createList((sorted) => { 25 | let speechOutput = "There are currently " + sorted.length + " Docker captains."; 26 | tellWithCard(speechOutput); 27 | }); 28 | } 29 | 30 | let createList = (next) => { 31 | let parser = new Parser(cheerio); 32 | 33 | request.get("https://www.docker.com/community/docker-captains", (err, res, text) => { 34 | let captains = parser.parse(text); 35 | 36 | let valid = 0; 37 | let sorted = captains.sort((x,y) => { 38 | if(x.text > y.text) { 39 | return 1; 40 | } 41 | else if(x.text < y.text) { 42 | return -1; 43 | } 44 | return 0; 45 | }); 46 | next(sorted); 47 | }); 48 | }; 49 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/oneshot.txt: -------------------------------------------------------------------------------- 1 | docker build -t captainsintent . ; docker service rm CaptainsIntent ; docker service create --network=functions --name CaptainsIntent captainsintent 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CaptainsIntent", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "cheerio": "^0.22.0", 14 | "get-stdin": "^5.0.1", 15 | "request": "^2.79.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/parser.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | 3 | 4 | module.exports = class Parser { 5 | 6 | constructor(cheerio) { 7 | this.modules = {"cheerio": cheerio }; 8 | } 9 | 10 | sanitize(handle) { 11 | let text = handle.toLowerCase(); 12 | if(text[0]== "@") { 13 | text = text.substring(1); 14 | } 15 | if(handle.indexOf("twitter.com") > -1) { 16 | text = text.substring(text.lastIndexOf("\/")+1) 17 | } 18 | return {text: text, valid: text.indexOf("http") == -1}; 19 | } 20 | 21 | parse(text) { 22 | let $ = this.modules.cheerio.load(text); 23 | 24 | let people = $("#captians .twitter_link a"); 25 | let handles = []; 26 | people.each((i, person) => { 27 | let handle = person.attribs.href; 28 | handles.push(this.sanitize(handle)); 29 | }); 30 | return handles; 31 | } 32 | }; -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/request.json: -------------------------------------------------------------------------------- 1 | { 2 | "session": { 3 | "sessionId": "SessionId.8b812aa4-765a-47b6-9949-b203e63c5480", 4 | "application": { 5 | "applicationId": "amzn1.ask.skill.72fb1025-aacc-4d05-a582-21344940c023" 6 | }, 7 | "attributes": {}, 8 | "user": { 9 | "userId": "amzn1.ask.account.AETXYOXCBUOCTUZE7WA2ZPZNDUMJRRZQNJ2H6NLQDVTMYXBX7JG2RA7C6PFLIM4PXVD7LIDGERLI6AJVK34KNWELGEOM33GRULMDO6XJRR77HALOUJR2YQS34UG27YCPOUGANQJDT4HMRFOWN4Z5E4VVTQ6Z5FIM6TYWFHQ2ZU6HQ47TBUMNGTQFTBIONEGELUCIEUXISRSEKOI" 10 | }, 11 | "new": true 12 | }, 13 | "request": { 14 | "type": "IntentRequest", 15 | "requestId": "EdwRequestId.cabcff07-8aaa-4fe6-aca0-94440051fc89", 16 | "locale": "en-GB", 17 | "timestamp": "2016-12-30T19:57:45Z", 18 | "intent": { 19 | "name": "CaptainsIntent", 20 | "slots": {} 21 | } 22 | }, 23 | "version": "1.0" 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cat request.json | node handler.js - 3 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/CaptainsIntent/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "response": { 4 | "outputSpeech": { 5 | "type": "PlainText", 6 | "text": "There's currently 6 people in space" 7 | }, 8 | "card": { 9 | "content": "There's currently 6 people in space", 10 | "title": "People in space", 11 | "type": "Simple" 12 | }, 13 | "shouldEndSession": true 14 | }, 15 | "sessionAttributes": {} 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | RUN apk --update add nodejs nodejs-npm 3 | 4 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin 5 | #COPY ./fwatchdog /usr/bin/ 6 | RUN chmod +x /usr/bin/fwatchdog 7 | 8 | COPY package.json . 9 | RUN npm i 10 | COPY handler.js . 11 | COPY sendColor.js . 12 | COPY sample_response.json . 13 | 14 | 15 | ENV fprocess="node handler.js" 16 | CMD ["fwatchdog"] 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/blue.json: -------------------------------------------------------------------------------- 1 | { 2 | "session": { 3 | "sessionId": "SessionId.3f589830-c369-45a3-9c8d-7f5271777dd8", 4 | "application": { 5 | "applicationId": "amzn1.ask.skill.b32fb0db-f0f0-4e64-b862-48e506f4ea68" 6 | }, 7 | "attributes": {}, 8 | "user": { 9 | "userId": "amzn1.ask.account.AEUHSFGVXWOYRSM2A7SVAK47L3I44TVOG6DBCTY2ACYSCUYQ65MWDZLUBZHLDD3XEMCYRLS4VSA54PQ7QBQW6FZLRJSMP5BOZE2B52YURUOSNOWORL44QGYDRXR3H7A7Y33OP3XKMUSJXIAFH7T2ZA6EQBLYRD34BPLTJXE3PDZE3V4YNFYUECXQNNH4TRG3ZBOYH2BF4BTKIIQ" 10 | }, 11 | "new": true 12 | }, 13 | "request": { 14 | "type": "IntentRequest", 15 | "requestId": "EdwRequestId.9ddf1ea0-c582-4dd0-8547-359f71639c1d", 16 | "locale": "en-GB", 17 | "timestamp": "2017-01-28T11:02:59Z", 18 | "intent": { 19 | "name": "ChangeColorIntent", 20 | "slots": { 21 | "LedColor": { 22 | "name": "LedColor", 23 | "value": "blue" 24 | } 25 | } 26 | } 27 | }, 28 | "version": "1.0" 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | docker build -t functions/alexa-leds:latest . 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/green.json: -------------------------------------------------------------------------------- 1 | { 2 | "session": { 3 | "sessionId": "SessionId.ce487e6e-9975-4c95-b305-2a0b354f3ee0", 4 | "application": { 5 | "applicationId": "amzn1.ask.skill.dc0c07b4-e18d-4f6f-a571-90cd1aca3bc6" 6 | }, 7 | "attributes": {}, 8 | "user": { 9 | "userId": "amzn1.ask.account.AEFGBTDIPL5K3HYKXGNAXDHANW2MPMFRRM5QX7FCMUEOJYCGNIVUTVR7IUUHZ2VFPIDNOPIUBWZLGYSSLOBLZ6FR5FRUJMP3OAZKUI3ZZ4ADLR7M4ROICY5H5RFASQLTV5IUNIOTA7OP6N2ZNCXXZDXS7BVGPB6GKIWZAJRHOGUYSBHX2JMSLNPQ6V6HMFKGKZLAWLHKGYEUDBI" 10 | }, 11 | "new": true 12 | }, 13 | "request": { 14 | "type": "IntentRequest", 15 | "requestId": "EdwRequestId.ee57cb67-a465-4d93-9ea8-29229f2634bc", 16 | "locale": "en-GB", 17 | "timestamp": "2017-01-28T11:32:04Z", 18 | "intent": { 19 | "name": "ChangeColorIntent", 20 | "slots": { 21 | "LedColor": { 22 | "name": "LedColor", 23 | "value": "green" 24 | } 25 | } 26 | } 27 | }, 28 | "version": "1.0" 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/off.json: -------------------------------------------------------------------------------- 1 | { 2 | "session": { 3 | "sessionId": "SessionId.3f589830-c369-45a3-9c8d-7f5271777dd8", 4 | "application": { 5 | "applicationId": "amzn1.ask.skill.b32fb0db-f0f0-4e64-b862-48e506f4ea68" 6 | }, 7 | "attributes": {}, 8 | "user": { 9 | "userId": "amzn1.ask.account.AEUHSFGVXWOYRSM2A7SVAK47L3I44TVOG6DBCTY2ACYSCUYQ65MWDZLUBZHLDD3XEMCYRLS4VSA54PQ7QBQW6FZLRJSMP5BOZE2B52YURUOSNOWORL44QGYDRXR3H7A7Y33OP3XKMUSJXIAFH7T2ZA6EQBLYRD34BPLTJXE3PDZE3V4YNFYUECXQNNH4TRG3ZBOYH2BF4BTKIIQ" 10 | }, 11 | "new": true 12 | }, 13 | "request": { 14 | "type": "IntentRequest", 15 | "requestId": "EdwRequestId.9ddf1ea0-c582-4dd0-8547-359f71639c1d", 16 | "locale": "en-GB", 17 | "timestamp": "2017-01-28T11:02:59Z", 18 | "intent": { 19 | "name": "TurnOffIntent", 20 | "slots": { 21 | "LedColor": { 22 | "name": "LedColor", 23 | "value": "red" 24 | } 25 | } 26 | } 27 | }, 28 | "version": "1.0" 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/oneshot.txt: -------------------------------------------------------------------------------- 1 | docker build -t changecolorintent . ; docker service rm ChangeColorIntent ; docker service create --network=functions --name ChangeColorIntent changecolorintent 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "src", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "get-stdin": "^5.0.1", 14 | "mqtt": "^2.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/red.json: -------------------------------------------------------------------------------- 1 | { 2 | "session": { 3 | "sessionId": "SessionId.3f589830-c369-45a3-9c8d-7f5271777dd8", 4 | "application": { 5 | "applicationId": "amzn1.ask.skill.b32fb0db-f0f0-4e64-b862-48e506f4ea68" 6 | }, 7 | "attributes": {}, 8 | "user": { 9 | "userId": "amzn1.ask.account.AEUHSFGVXWOYRSM2A7SVAK47L3I44TVOG6DBCTY2ACYSCUYQ65MWDZLUBZHLDD3XEMCYRLS4VSA54PQ7QBQW6FZLRJSMP5BOZE2B52YURUOSNOWORL44QGYDRXR3H7A7Y33OP3XKMUSJXIAFH7T2ZA6EQBLYRD34BPLTJXE3PDZE3V4YNFYUECXQNNH4TRG3ZBOYH2BF4BTKIIQ" 10 | }, 11 | "new": true 12 | }, 13 | "request": { 14 | "type": "IntentRequest", 15 | "requestId": "EdwRequestId.9ddf1ea0-c582-4dd0-8547-359f71639c1d", 16 | "locale": "en-GB", 17 | "timestamp": "2017-01-28T11:02:59Z", 18 | "intent": { 19 | "name": "ChangeColorIntent", 20 | "slots": { 21 | "LedColor": { 22 | "name": "LedColor", 23 | "value": "red" 24 | } 25 | } 26 | } 27 | }, 28 | "version": "1.0" 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/sample_request.json: -------------------------------------------------------------------------------- 1 | { 2 | "session": { 3 | "sessionId": "SessionId.3f589830-c369-45a3-9c8d-7f5271777dd8", 4 | "application": { 5 | "applicationId": "amzn1.ask.skill.b32fb0db-f0f0-4e64-b862-48e506f4ea68" 6 | }, 7 | "attributes": {}, 8 | "user": { 9 | "userId": "amzn1.ask.account.AEUHSFGVXWOYRSM2A7SVAK47L3I44TVOG6DBCTY2ACYSCUYQ65MWDZLUBZHLDD3XEMCYRLS4VSA54PQ7QBQW6FZLRJSMP5BOZE2B52YURUOSNOWORL44QGYDRXR3H7A7Y33OP3XKMUSJXIAFH7T2ZA6EQBLYRD34BPLTJXE3PDZE3V4YNFYUECXQNNH4TRG3ZBOYH2BF4BTKIIQ" 10 | }, 11 | "new": true 12 | }, 13 | "request": { 14 | "type": "IntentRequest", 15 | "requestId": "EdwRequestId.9ddf1ea0-c582-4dd0-8547-359f71639c1d", 16 | "locale": "en-GB", 17 | "timestamp": "2017-01-28T11:02:59Z", 18 | "intent": { 19 | "name": "ChangeColorIntent", 20 | "slots": { 21 | "LedColor": { 22 | "name": "LedColor", 23 | "value": "blue" 24 | } 25 | } 26 | } 27 | }, 28 | "version": "1.0" 29 | } -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/sample_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "response": { 4 | "outputSpeech": { 5 | "type": "PlainText", 6 | "text": "OK, red." 7 | }, 8 | "card": { 9 | "content": "OK, red.", 10 | "title": "Office Lights", 11 | "type": "Simple" 12 | }, 13 | "shouldEndSession": true 14 | }, 15 | "sessionAttributes": {} 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ChangeColorIntent/sendColor.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | 3 | var mqtt = require('mqtt'); 4 | 5 | class Send { 6 | constructor(topic) { 7 | this.topic = topic; 8 | } 9 | 10 | sendIntensity(req, done) { 11 | var ops = { port: 1883, host: "iot.eclipse.org" }; 12 | 13 | var client = mqtt.connect(ops); 14 | 15 | client.on('connect', () => { 16 | 17 | let payload = req; 18 | let cb = () => { 19 | done(); 20 | }; 21 | client.publish(this.topic, JSON.stringify(payload), {qos: 1}, cb); 22 | }); 23 | } 24 | 25 | sendColor(req, done) { 26 | var ops = { port: 1883, host: "iot.eclipse.org" }; 27 | 28 | var client = mqtt.connect(ops); 29 | let cb = () => { 30 | done(); 31 | }; 32 | client.on('connect', () => { 33 | 34 | let payload = req; 35 | client.publish(this.topic, JSON.stringify(payload), {qos: 1}, cb); 36 | }); 37 | } 38 | } 39 | 40 | module.exports = Send; -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/DockerHubStats/.gitignore: -------------------------------------------------------------------------------- 1 | DockerHubStats 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/DockerHubStats/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.9.2-alpine as builder 2 | 3 | MAINTAINER alex@openfaas.com 4 | ENTRYPOINT [] 5 | 6 | RUN apk --no-cache add make curl \ 7 | && curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog > /usr/bin/fwatchdog \ 8 | && chmod +x /usr/bin/fwatchdog 9 | 10 | WORKDIR /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats 11 | 12 | COPY . /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats 13 | 14 | RUN make install 15 | 16 | FROM alpine:3.6 17 | 18 | # Needed to reach the hub 19 | RUN apk --no-cache add ca-certificates 20 | 21 | COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog 22 | COPY --from=builder /go/bin/DockerHubStats /usr/bin/DockerHubStats 23 | ENV fprocess "/usr/bin/DockerHubStats" 24 | 25 | HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1 26 | CMD ["/usr/bin/fwatchdog"] 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/DockerHubStats/Dockerfile.armhf: -------------------------------------------------------------------------------- 1 | FROM golang:1.9.2-alpine as builder 2 | 3 | MAINTAINER alex@openfaas.com 4 | ENTRYPOINT [] 5 | 6 | RUN apk --no-cache add make curl \ 7 | && curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog-armhf > /usr/bin/fwatchdog \ 8 | && chmod +x /usr/bin/fwatchdog 9 | 10 | WORKDIR /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats 11 | 12 | COPY . /go/src/github.com/openfaas/faas/sample-functions/DockerHubStats 13 | 14 | RUN make install 15 | 16 | FROM alpine:3.6 17 | 18 | # Needed to reach the hub 19 | RUN apk --no-cache add ca-certificates 20 | 21 | COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog 22 | COPY --from=builder /go/bin/DockerHubStats /usr/bin/DockerHubStats 23 | ENV fprocess "/usr/bin/DockerHubStats" 24 | 25 | CMD ["/usr/bin/fwatchdog"] 26 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/DockerHubStats/Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: install 3 | 4 | install: 5 | @go install . 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/DockerHubStats/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "log" 8 | "net/http" 9 | "os" 10 | "strings" 11 | ) 12 | 13 | type dockerHubStatsType struct { 14 | Count int `json:"count"` 15 | } 16 | 17 | func sanitizeInput(input string) string { 18 | parts := strings.Split(input, "\n") 19 | return strings.Trim(parts[0], " ") 20 | } 21 | 22 | func requestHubStats(org string) dockerHubStatsType { 23 | client := http.Client{} 24 | res, err := client.Get("https://hub.docker.com/v2/repositories/" + org) 25 | if err != nil { 26 | log.Fatalln("Unable to reach Docker Hub server.") 27 | } 28 | 29 | body, err := ioutil.ReadAll(res.Body) 30 | if err != nil { 31 | log.Fatalln("Unable to parse response from server.") 32 | } 33 | 34 | dockerHubStats := dockerHubStatsType{} 35 | json.Unmarshal(body, &dockerHubStats) 36 | return dockerHubStats 37 | } 38 | 39 | func main() { 40 | input, err := ioutil.ReadAll(os.Stdin) 41 | if err != nil { 42 | log.Fatal("Unable to read standard input:", err) 43 | } 44 | org := string(input) 45 | if len(input) == 0 { 46 | log.Fatalln("A username or organisation is required.") 47 | } 48 | 49 | org = sanitizeInput(org) 50 | dockerHubStats := requestHubStats(org) 51 | 52 | fmt.Printf("The organisation or user %s has %d repositories on the Docker hub.\n", org, dockerHubStats.Count) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/HostnameIntent/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | RUN apk --update add nodejs nodejs-npm 3 | 4 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog /usr/bin 5 | RUN chmod +x /usr/bin/fwatchdog 6 | 7 | COPY package.json . 8 | COPY handler.js . 9 | COPY sample.json . 10 | 11 | RUN npm i 12 | ENV fprocess="node handler.js" 13 | CMD ["fwatchdog"] 14 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/HostnameIntent/handler.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | let fs = require('fs'); 3 | let sample = require("./sample.json"); 4 | let getStdin = require("get-stdin"); 5 | 6 | getStdin().then(content => { 7 | let request = JSON.parse(content); 8 | handle(request, request.request.intent); 9 | }); 10 | 11 | function tellWithCard(speechOutput) { 12 | sample.response.outputSpeech.text = speechOutput 13 | sample.response.card.content = speechOutput 14 | sample.response.card.title = "Hostname"; 15 | console.log(JSON.stringify(sample)); 16 | process.exit(0); 17 | } 18 | 19 | function handle(request, intent) { 20 | fs.readFile("/etc/hostname", "utf8", (err, data) => { 21 | if(err) { 22 | return console.log(err); 23 | } 24 | tellWithCard("Your hostname is " + data); 25 | }); 26 | }; 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/HostnameIntent/oneshot.txt: -------------------------------------------------------------------------------- 1 | docker build -t hostnameintent . ; docker service rm HostnameIntent ; docker service create --network=functions --name HostnameIntent hostnameintent 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/HostnameIntent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "HostnameIntent", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "get-stdin": "^5.0.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/HostnameIntent/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "response": { 4 | "outputSpeech": { 5 | "type": "PlainText", 6 | "text": "There's currently 6 people in space" 7 | }, 8 | "card": { 9 | "content": "There's currently 6 people in space", 10 | "title": "People in space", 11 | "type": "Simple" 12 | }, 13 | "shouldEndSession": true 14 | }, 15 | "sessionAttributes": {} 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/MarkdownRender/.gitignore: -------------------------------------------------------------------------------- 1 | app 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/MarkdownRender/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.9.2-alpine as builder 2 | 3 | MAINTAINER alex@openfaas.com 4 | ENTRYPOINT [] 5 | 6 | RUN apk --no-cache add make curl \ 7 | && curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog > /usr/bin/fwatchdog \ 8 | && chmod +x /usr/bin/fwatchdog 9 | 10 | WORKDIR /go/src/github.com/openfaas/faas/sample-functions/MarkdownRender 11 | 12 | COPY handler.go . 13 | COPY vendor vendor 14 | 15 | RUN go install 16 | 17 | FROM alpine:3.6 18 | 19 | # Needed to reach the hub 20 | RUN apk --no-cache add ca-certificates 21 | 22 | COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog 23 | COPY --from=builder /go/bin/MarkdownRender /usr/bin/MarkdownRender 24 | ENV fprocess "/usr/bin/MarkdownRender" 25 | 26 | CMD ["/usr/bin/fwatchdog"] 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/MarkdownRender/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | name = "github.com/microcosm-cc/bluemonday" 7 | packages = ["."] 8 | revision = "68fecaef60268522d2ac3f0123cec9d3bcab7b6e" 9 | 10 | [[projects]] 11 | name = "github.com/russross/blackfriday" 12 | packages = ["."] 13 | revision = "cadec560ec52d93835bf2f15bd794700d3a2473b" 14 | version = "v2.0.0" 15 | 16 | [[projects]] 17 | branch = "master" 18 | name = "github.com/shurcooL/sanitized_anchor_name" 19 | packages = ["."] 20 | revision = "86672fcb3f950f35f2e675df2240550f2a50762f" 21 | 22 | [[projects]] 23 | branch = "master" 24 | name = "golang.org/x/net" 25 | packages = ["html","html/atom"] 26 | revision = "a337091b0525af65de94df2eb7e98bd9962dcbe2" 27 | 28 | [solve-meta] 29 | analyzer-name = "dep" 30 | analyzer-version = 1 31 | inputs-digest = "501ddd966c3f040b4158a459f36eeda2818e57897613b965188a4f4b15579034" 32 | solver-name = "gps-cdcl" 33 | solver-version = 1 34 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/MarkdownRender/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | 24 | [[constraint]] 25 | branch = "master" 26 | name = "github.com/microcosm-cc/bluemonday" 27 | 28 | [[constraint]] 29 | name = "github.com/russross/blackfriday" 30 | version = "2.0.0" 31 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/MarkdownRender/MarkdownRender: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/sample-functions/MarkdownRender/MarkdownRender -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/MarkdownRender/handler.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | 8 | "github.com/microcosm-cc/bluemonday" 9 | "github.com/russross/blackfriday" 10 | ) 11 | 12 | func main() { 13 | input, _ := ioutil.ReadAll(os.Stdin) 14 | unsafe := blackfriday.Run([]byte(input), blackfriday.WithNoExtensions()) 15 | html := bluemonday.UGCPolicy().SanitizeBytes(unsafe) 16 | fmt.Println(string(html)) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | 3 | RUN apk --update add nodejs nodejs-npm 4 | 5 | ADD https://github.com/openfaas/faas/releases/download/0.6.0/fwatchdog /usr/bin 6 | RUN chmod +x /usr/bin/fwatchdog 7 | 8 | COPY package.json . 9 | COPY main.js . 10 | RUN npm i 11 | ENV fprocess="node main.js" 12 | CMD ["fwatchdog"] 13 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/Dockerfile.arm64: -------------------------------------------------------------------------------- 1 | FROM arm64v8/alpine:3.6 2 | 3 | RUN apk --update add nodejs nodejs-npm 4 | 5 | ADD https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog-arm64 /usr/bin/fwatchdog 6 | RUN chmod +x /usr/bin/fwatchdog 7 | 8 | COPY package.json . 9 | COPY main.js . 10 | RUN npm i 11 | ENV fprocess="node main.js" 12 | CMD ["fwatchdog"] 13 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/Dockerfile.armhf: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | RUN apk --no-cache add nodejs nodejs-npm 3 | 4 | ADD https://github.com/openfaas/faas/releases/download/0.6.0/fwatchdog-armhf /usr/bin/fwatchdog 5 | RUN chmod +x /usr/bin/fwatchdog 6 | 7 | COPY package.json . 8 | COPY main.js . 9 | RUN npm i 10 | ENV fprocess="node main.js" 11 | HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1 12 | CMD ["fwatchdog"] 13 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/Dockerfile.func: -------------------------------------------------------------------------------- 1 | FROM functions/nodebase:alpine-6.9.1 2 | 3 | COPY handler.js . 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/build.armhf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -f Dockerfile.armhf -t functions/nodeinfo:latest-armhf . 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/build.func.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t functions/nodeinfo:func . -f Dockerfile.func 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build --squash -t functions/nodeinfo . 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/handler.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | let os = require('os'); 3 | let fs = require('fs'); 4 | let util = require('util'); 5 | 6 | module.exports = (content, callback) => { 7 | fs.readFile("/etc/hostname", "utf8", (err, data) => { 8 | let val = ""; 9 | val += "Hostname: " + data +"\n"; 10 | val += "Platform: " + os.platform()+"\n"; 11 | val += "Arch: " + os.arch() + "\n"; 12 | val += "CPU count: " + os.cpus().length+ "\n"; 13 | 14 | val += "Uptime: " + os.uptime()+ "\n"; 15 | 16 | if (content && content.length && content.indexOf("verbose") > -1) { 17 | val += util.inspect(os.cpus()) + "\n"; 18 | val += util.inspect(os.networkInterfaces())+ "\n"; 19 | } 20 | 21 | callback(null, val); 22 | }); 23 | }; 24 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/main.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | let os = require('os'); 3 | let fs = require('fs'); 4 | 5 | const getStdin = require('get-stdin'); 6 | 7 | getStdin().then((content) => { 8 | fs.readFile("/etc/hostname", "utf8", (err, data) => { 9 | console.log("Hostname: " + data); 10 | console.log("Platform: " + os.platform()); 11 | console.log("Arch: " + os.arch()); 12 | console.log("CPU count: " + os.cpus().length); 13 | console.log("Uptime: " + os.uptime()) 14 | if (content && content.length && content.indexOf("verbose") > -1) { 15 | console.log(os.cpus()); 16 | console.log(os.networkInterfaces()); 17 | } 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/NodeInfo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample-functions", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "main.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "get-stdin": "^5.0.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/Phantomjs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alexellis2/phantomjs-docker:latest 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.5.6-alpha/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | ENV fprocess="phantomjs /dev/stdin" 7 | 8 | HEALTHCHECK --interval=5s CMD [ -e /tmp/.lock ] || exit 1 9 | CMD ["fwatchdog"] 10 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/Phantomjs/README.md: -------------------------------------------------------------------------------- 1 | ### Phantomjs function 2 | 3 | [Phantomjs](http://phantomjs.org) is a headless web-browser used for scraping and automation testing. This function will scrape a web-page with the JavaScript sent in through the function. 4 | 5 | Once a function has been deployed to FaaS using the UI or one of the other methods you can invoke it with a JavaScript Phantomjs file. 6 | 7 | **Image name:** `functions/base:phantomjs` 8 | 9 | You can use the existing Docker image that is managed through this project. 10 | 11 | Create the function through the FaaS CLI: 12 | 13 | ``` 14 | # curl -sSL https://get.openfaas.com | sudo sh 15 | 16 | # faas-cli -action=deploy -image=functions/base:phantomjs -name=phantomjs \ 17 | -fprocess="phantomjs /dev/stdin" 18 | 200 OK 19 | URL: http://localhost:8080/function/phantomjs 20 | ``` 21 | 22 | **Example usage:** 23 | 24 | ``` 25 | $ time curl --data-binary @cnn.js http://localhost:8080/function/phantomjs 26 | 27 | Status: success 28 | CNN - Breaking News, Latest News and Videos 29 | 30 | real 0m8.729s 31 | ``` 32 | 33 | This script visits the front page of CNN and once it is fully loaded - scrapes the title. 34 | 35 | See [cnn.js](https://github.com/openfaas/faas/tree/master/sample-functions/Phantomjs/cnn.js) as an example of a Phantomjs script. 36 | 37 | Another example script [feedly_subscribers.js](https://github.com/openfaas/faas/tree/master/sample-functions/Phantomjs/feedly_subscribers.js) gives the count of subscribers for an RSS Feed registered on Feedly. 38 | 39 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/Phantomjs/cnn.js: -------------------------------------------------------------------------------- 1 | var webPage = require('webpage'); 2 | var page = webPage.create(); 3 | 4 | page.open('https://www.cnn.com/', function(status) { 5 | console.log('Status: ' + status); 6 | console.log(page.title); 7 | // Do other things here... 8 | phantom.exit(); 9 | 10 | }); 11 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/Phantomjs/feedly_subscribers.js: -------------------------------------------------------------------------------- 1 | var webPage = require('webpage'); 2 | var page = webPage.create(); 3 | 4 | var feed = "http://blog.alexellis.io/rss/"; 5 | var url = "https://feedly.com/i/subscription/feed/" + feed; 6 | 7 | page.open(url, function(status) { 8 | var title = page.evaluate(function(s) { 9 | return document.querySelector(s).innerText; 10 | }, ".count-followers"); 11 | console.log(title.split(" ")[0]); 12 | phantom.exit(); 13 | }); 14 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/.gitignore: -------------------------------------------------------------------------------- 1 | small_gordon.png 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM v4tech/imagemagick 2 | 3 | ADD https://github.com/openfaas/faas/releases/download/0.5.2-alpha/fwatchdog /usr/bin 4 | RUN chmod +x /usr/bin/fwatchdog 5 | 6 | ENV fprocess "convert - -resize 50% fd:1" 7 | 8 | EXPOSE 8080 9 | 10 | CMD [ "/usr/bin/fwatchdog"] 11 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/Dockerfile.armhf: -------------------------------------------------------------------------------- 1 | FROM arm32v6/alpine:3.6 2 | 3 | RUN apk --no-cache add imagemagick 4 | 5 | ADD https://github.com/openfaas/faas/releases/download/0.6.0/fwatchdog-armhf /usr/bin/fwatchdog 6 | RUN chmod +x /usr/bin/fwatchdog 7 | 8 | ENV fprocess "convert - -resize 50% fd:1" 9 | 10 | EXPOSE 8080 11 | 12 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 13 | CMD [ "/usr/bin/fwatchdog"] 14 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/README.md: -------------------------------------------------------------------------------- 1 | ## functions/resizer 2 | 3 | ![](https://github.com/openfaas/faas/blob/master/sample-functions/ResizeImageMagick/gordon.png) 4 | 5 | Use this FaaS function to resize an image with ImageMagick. 6 | 7 | **Deploy the resizer function** 8 | 9 | (Make sure you have already deployed FaaS with ./deploy_stack.sh in the root of this Github repository. 10 | 11 | * Option 1 - click *Create a new function* on the FaaS UI 12 | 13 | * Option 2 - use the [faas-cli](https://github.com/openfaas/faas-cli/) (experimental) 14 | 15 | ``` 16 | # curl -sSL https://get.openfaas.com | sudo sh 17 | 18 | # faas-cli -action=deploy -image=functions/resizer -name=resizer \ 19 | -fprocess="convert - -resize 50% fd:1" 20 | 200 OK 21 | URL: http://localhost:8080/function/resizer 22 | ``` 23 | 24 | **Resize a picture by 50%** 25 | 26 | Now pick an image such as the included picture of Gordon and use `curl` or a tool of your choice to send the data to the function. Pipe the result into a new file like this: 27 | 28 | ``` 29 | $ curl localhost:8080/function/resizer --data-binary @gordon.png > small_gordon.png 30 | ``` 31 | 32 | **Customize the transformation** 33 | 34 | If you want to customise the transformation then edit the Dockerfile or the fprocess variable and create a new function. 35 | 36 | **Remove the function** 37 | 38 | You can remove the function with `docker service rm resizer`. 39 | 40 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/build.armhf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/resizer:armhf..." 4 | docker build -t functions/resizer:armhf -f Dockerfile.armhf . 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | docker build -t functions/resizer . 4 | 5 | echo Built functions/resizer 6 | 7 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/gordon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/realbot/faas-dcos/11a2ac079140f3b0265a949bc554d3c4a5325aad/vendor/github.com/openfaas/faas/sample-functions/ResizeImageMagick/gordon.png -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/SentimentAnalysis/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7-alpine 2 | 3 | RUN pip install textblob && \ 4 | python -m textblob.download_corpora 5 | 6 | ADD https://github.com/openfaas/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin 7 | RUN chmod +x /usr/bin/fwatchdog 8 | 9 | WORKDIR /root/ 10 | 11 | COPY handler.py . 12 | 13 | ENV fprocess="python handler.py" 14 | 15 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 16 | 17 | CMD ["fwatchdog"] 18 | 19 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/SentimentAnalysis/Dockerfile.armhf: -------------------------------------------------------------------------------- 1 | FROM arm32v7/python:2.7-slim 2 | 3 | RUN pip install textblob && \ 4 | python -m textblob.download_corpora 5 | 6 | ADD https://github.com/openfaas/faas/releases/download/0.6.0/fwatchdog-armhf /usr/bin/fwatchdog 7 | RUN chmod +x /usr/bin/fwatchdog 8 | 9 | WORKDIR /root/ 10 | 11 | COPY handler.py . 12 | 13 | ENV fprocess="python handler.py" 14 | 15 | HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1 16 | 17 | CMD ["fwatchdog"] 18 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/SentimentAnalysis/README.md: -------------------------------------------------------------------------------- 1 | ## SentimentAnalysis 2 | 3 | Python function provides a rating on sentiment positive/negative (polarity -1.0-1.0) and subjectivity to provided to each of the sentences sent in via the [TextBlob project](http://textblob.readthedocs.io/en/dev/). 4 | 5 | Example: 6 | 7 | Run in the function: 8 | 9 | ``` 10 | # curl -s --fail localhost:8080/system/functions -d \ 11 | '{ 12 | "service": "sentimentanalysis", 13 | "image": "functions/sentimentanalysis", 14 | "envProcess": "python ./handler.py", 15 | "network": "func_functions" 16 | }' 17 | ``` 18 | 19 | Now test the function: 20 | 21 | ``` 22 | # curl localhost:8080/function/sentimentanalysis -d "Personally I like functions to do one thing and only one thing well, it makes them more readable." 23 | Polarity: 0.166666666667 Subjectivity: 0.6 24 | 25 | # curl localhost:8080/function/sentimentanalysis -d "Functions are great and proven to be awesome" 26 | Polarity: 0.9 Subjectivity: 0.875 27 | 28 | # curl localhost:8080/function/sentimentanalysis -d "The hotel was clean, but the area was terrible"; echo 29 | Polarity: -0.316666666667 Subjectivity: 0.85 30 | ``` 31 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/SentimentAnalysis/build.armhf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/sentimentanalysis:armhf..." 4 | docker build -t functions/sentimentanalysis:armhf . -f Dockerfile.armhf 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/SentimentAnalysis/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Building functions/sentimentanalysis" 4 | docker build -t functions/sentimentanalysis . 5 | 6 | 7 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/SentimentAnalysis/handler.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import json 3 | from textblob import TextBlob 4 | 5 | # Set encoding to UTF-8 (vs ASCII to eliminate potential errors). 6 | reload(sys) 7 | sys.setdefaultencoding('utf8') 8 | 9 | def get_stdin(): 10 | buf = "" 11 | for line in sys.stdin: 12 | buf = buf + line 13 | return buf 14 | 15 | if(__name__ == "__main__"): 16 | st = get_stdin() 17 | blob = TextBlob(st) 18 | res = { 19 | "polarity": 0, 20 | "subjectivity": 0 21 | } 22 | 23 | for sentence in blob.sentences: 24 | res["subjectivity"] = res["subjectivity"] + sentence.sentiment.subjectivity 25 | res["polarity"] = res["polarity"] + sentence.sentiment.polarity 26 | 27 | total = len(blob.sentences) 28 | 29 | res["sentence_count"] = total 30 | res["polarity"] = res["polarity"] / total 31 | res["subjectivity"] = res["subjectivity"] / total 32 | 33 | print(json.dumps(res)) 34 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/WebhookStash/.gitignore: -------------------------------------------------------------------------------- 1 | app 2 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/WebhookStash/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.9.2-alpine as builder 2 | 3 | MAINTAINER alex@openfaas.com 4 | ENTRYPOINT [] 5 | 6 | RUN apk --no-cache add make curl \ 7 | && curl -sL https://github.com/openfaas/faas/releases/download/0.6.9/fwatchdog > /usr/bin/fwatchdog \ 8 | && chmod +x /usr/bin/fwatchdog 9 | 10 | WORKDIR /go/src/github.com/openfaas/faas/sample-functions/WebhookStash 11 | 12 | COPY handler.go . 13 | # COPY vendor vendor 14 | 15 | RUN go install 16 | 17 | FROM alpine:3.6 18 | 19 | # Needed to reach the hub 20 | RUN apk --no-cache add ca-certificates 21 | 22 | COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog 23 | COPY --from=builder /go/bin/WebhookStash /usr/bin/WebhookStash 24 | ENV fprocess "/usr/bin/WebhookStash" 25 | 26 | CMD ["/usr/bin/fwatchdog"] 27 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/WebhookStash/README.md: -------------------------------------------------------------------------------- 1 | WebhookStash 2 | ============ 3 | 4 | Example serverless function shows how to stash way contents of webhooks called via API gateway. 5 | 6 | Each file is saved with the UNIX timestamp in nano seconds plus an extension of .txt 7 | 8 | Example: 9 | 10 | ``` 11 | # curl -X POST -v -d @$HOME/.ssh/id_rsa.pub localhost:8080/function/webhookstash 12 | ``` 13 | 14 | Then if you find the replica you can check the disk: 15 | 16 | ``` 17 | # docker exec webhookstash.1.z054csrh70tgk9s5k4bb8uefq find 18 | ``` 19 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/WebhookStash/handler.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "strconv" 8 | "time" 9 | "log" 10 | ) 11 | 12 | func main() { 13 | input, err := ioutil.ReadAll(os.Stdin) 14 | if err != nil { 15 | log.Fatalf("Cannot read input %s.\n", err) 16 | return 17 | } 18 | now := time.Now() 19 | stamp := strconv.FormatInt(now.UnixNano(), 10) 20 | 21 | writeErr := ioutil.WriteFile(stamp+".txt", input, 0644) 22 | if writeErr != nil { 23 | log.Fatalf("Cannot write input %s.\n", err) 24 | return 25 | } 26 | 27 | fmt.Printf("Stashing request: %s.txt\n", stamp) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/WordCountFunction/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alexellis2/faas-alpinefunction:latest 2 | 3 | # Populate example here 4 | ENV fprocess="wc" 5 | CMD ["fwatchdog"] 6 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/WordCountFunction/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build -t alexellis2/faas-wordcount:latest . 4 | 5 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/build_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | faas-cli build -f samples.yml --parallel 4 4 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/echo/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM functions/alpine:latest 2 | ENV fprocess "/bin/cat" 3 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/gif-maker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.6 2 | 3 | RUN apk --no-cache add ffmpeg gifsicle curl \ 4 | && curl -LS https://github.com/openfaas/faas/releases/download/0.5.6-alpha/fwatchdog > /usr/bin/fwatchdog \ 5 | && chmod +x /usr/bin/fwatchdog \ 6 | && apk del curl 7 | WORKDIR /root/ 8 | COPY entry.sh . 9 | ENV fprocess="./entry.sh" 10 | CMD ["fwatchdog"] 11 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/gif-maker/README.md: -------------------------------------------------------------------------------- 1 | gif-maker 2 | ========= 3 | 4 | Converts a .mov QuickTime video to a .gif 5 | 6 | Testing: 7 | 8 | ``` 9 | $ docker build -t alexellis/gif-maker . 10 | $ faas-cli deploy --fprocess="./entry.sh" \ 11 | --env read_timeout=60 --env write_timeout=60 \ 12 | --image alexellis/gif-maker --name gif-maker 13 | 14 | # wait a little 15 | 16 | $ curl http://localhost:8080/function/gif-maker --data-binary @$HOME/Desktop/screen1.mov > screen1.gif 17 | ``` 18 | 19 | Try to use a small cropped video around 5MB. Timeouts may need to be extended for larger videos 20 | 21 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/sample-functions/gif-maker/entry.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | export nano=`date +%s%N` 3 | # -s 600x400 4 | cat - > ./$nano.mov 5 | ffmpeg -loglevel panic -i $nano.mov -vf scale=iw*.5:ih*.5 -pix_fmt rgb24 -r 20 -f gif - | gifsicle --optimize=3 --delay=3 > /dev/stdout \ 6 | && rm $nano.mov 7 | 8 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/watchdog/.gitignore: -------------------------------------------------------------------------------- 1 | fwatchdog 2 | watchdog 3 | fwatchdog-armhf 4 | fwatchdog.exe 5 | watchdog.exe 6 | fwatchdog-arm64 7 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/watchdog/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.8.5 2 | RUN mkdir -p /go/src/github.com/openfaas/faas/watchdog 3 | WORKDIR /go/src/github.com/openfaas/faas/watchdog 4 | 5 | COPY main.go . 6 | COPY readconfig.go . 7 | COPY config_test.go . 8 | COPY requesthandler_test.go . 9 | #COPY fastForkRequestHandler.go . 10 | #COPY requestHandler.go . 11 | COPY types types 12 | 13 | # Run a gofmt and exclude all vendored code. 14 | RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" 15 | 16 | RUN go test -v ./... 17 | 18 | # Stripping via -ldflags "-s -w" 19 | RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o watchdog . \ 20 | && GOARM=6 GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o watchdog-armhf . \ 21 | && GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o watchdog-arm64 . \ 22 | && GOOS=windows CGO_ENABLED=0 go build -a -ldflags "-s -w" -installsuffix cgo -o watchdog.exe . 23 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/watchdog/Makefile: -------------------------------------------------------------------------------- 1 | linux: 2 | CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-s -w" -installsuffix cgo -o fwatchdog 3 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/watchdog/build.ps1: -------------------------------------------------------------------------------- 1 | cd watchdog 2 | 3 | del watchdog.exe 4 | 5 | docker build -t alexellis2/watchdog:windows . -f .\Dockerfile.win 6 | 7 | docker create --name watchdog alexellis2/watchdog:windows cmd 8 | 9 | & docker cp watchdog:/go/src/github.com/openfaas/faas/watchdog/watchdog.exe . 10 | docker rm -f watchdog 11 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/watchdog/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export arch=$(uname -m) 4 | 5 | if [ "$arch" = "armv7l" ] ; then 6 | echo "Build not supported on $arch, use cross-build." 7 | exit 1 8 | fi 9 | 10 | if [ ! $http_proxy == "" ] 11 | then 12 | docker build --no-cache --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t functions/watchdog:build . 13 | else 14 | docker build -t functions/watchdog:build . 15 | fi 16 | 17 | docker create --name buildoutput functions/watchdog:build echo 18 | 19 | docker cp buildoutput:/go/src/github.com/openfaas/faas/watchdog/watchdog ./fwatchdog 20 | docker cp buildoutput:/go/src/github.com/openfaas/faas/watchdog/watchdog-armhf ./fwatchdog-armhf 21 | docker cp buildoutput:/go/src/github.com/openfaas/faas/watchdog/watchdog-arm64 ./fwatchdog-arm64 22 | docker cp buildoutput:/go/src/github.com/openfaas/faas/watchdog/watchdog.exe ./fwatchdog.exe 23 | 24 | docker rm buildoutput 25 | 26 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas/watchdog/types/types.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package types 5 | 6 | import ( 7 | "encoding/json" 8 | "net/http" 9 | "os" 10 | ) 11 | 12 | // OsEnv implements interface to wrap os.Getenv 13 | type OsEnv struct { 14 | } 15 | 16 | // Getenv wraps os.Getenv 17 | func (OsEnv) Getenv(key string) string { 18 | return os.Getenv(key) 19 | } 20 | 21 | type MarshalBody struct { 22 | Raw []byte `json:"raw"` 23 | } 24 | 25 | type MarshalReq struct { 26 | Header http.Header `json:"header"` 27 | Body MarshalBody `json:"body"` 28 | } 29 | 30 | func UnmarshalRequest(data []byte) (*MarshalReq, error) { 31 | request := MarshalReq{} 32 | err := json.Unmarshal(data, &request) 33 | return &request, err 34 | } 35 | 36 | func MarshalRequest(data []byte, header *http.Header) ([]byte, error) { 37 | req := MarshalReq{ 38 | Body: MarshalBody{ 39 | Raw: data, 40 | }, 41 | Header: *header, 42 | } 43 | 44 | res, marshalErr := json.Marshal(&req) 45 | return res, marshalErr 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/realbot/faas-provider/.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 14 | .glide/ 15 | 16 | faas-backend 17 | -------------------------------------------------------------------------------- /vendor/github.com/realbot/faas-provider/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.8.3 2 | 3 | RUN mkdir -p /go/src/github.com/openfaas/faas-provider/ 4 | 5 | WORKDIR /go/src/github.com/openfaas/faas-provider 6 | 7 | COPY vendor vendor 8 | COPY types types 9 | COPY serve.go . 10 | 11 | RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o faas-provider . 12 | 13 | FROM alpine:3.5 14 | RUN apk --no-cache add ca-certificates 15 | WORKDIR /root/ 16 | 17 | EXPOSE 8080 18 | ENV http_proxy "" 19 | ENV https_proxy "" 20 | 21 | COPY --from=0 /go/src/github.com/openfaas/faas-provider/faas-provider . 22 | 23 | CMD ["./faas-provider] 24 | -------------------------------------------------------------------------------- /vendor/github.com/realbot/faas-provider/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/realbot/faas-provider/README.md: -------------------------------------------------------------------------------- 1 | faas-provider 2 | ============== 3 | 4 | This is a common template or interface for you to start building your own OpenFaaS backend. 5 | 6 | Checkout the [backends guide here](https://github.com/openfaas/faas/blob/master/guide/backends.md) before starting. 7 | 8 | OpenFaaS projects use the MIT License and are written in Golang. We encourage the same for external / third-party providers. 9 | 10 | ### How to use this code 11 | 12 | We will setup all the standard HTTP routes for you, then start listening on a given TCP port - it should be 8080. 13 | 14 | Just implement the supplied routes. 15 | 16 | For an example checkout the [server.go](https://github.com/openfaas/faas-netes/blob/master/server.go) file in the [faas-netes](https://github.com/openfaas/faas-netes) Kubernetes backend. 17 | 18 | I.e.: 19 | 20 | ```golang 21 | bootstrapHandlers := bootTypes.FaaSHandlers{ 22 | FunctionProxy: handlers.MakeProxy(), 23 | DeleteHandler: handlers.MakeDeleteHandler(clientset), 24 | DeployHandler: handlers.MakeDeployHandler(clientset), 25 | FunctionReader: handlers.MakeFunctionReader(clientset), 26 | ReplicaReader: handlers.MakeReplicaReader(clientset), 27 | ReplicaUpdater: handlers.MakeReplicaUpdater(clientset), 28 | } 29 | var port int 30 | port = 8080 31 | bootstrapConfig := bootTypes.FaaSConfig{ 32 | ReadTimeout: time.Second * 8, 33 | WriteTimeout: time.Second * 8, 34 | TCPPort: &port, 35 | } 36 | 37 | bootstrap.Serve(&bootstrapHandlers, &bootstrapConfig) 38 | ``` 39 | -------------------------------------------------------------------------------- /vendor/github.com/realbot/faas-provider/types/config.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "net/http" 5 | "time" 6 | ) 7 | 8 | // FaaSHandlers provide handlers for OpenFaaS 9 | type FaaSHandlers struct { 10 | FunctionReader http.HandlerFunc 11 | DeployHandler http.HandlerFunc 12 | DeleteHandler http.HandlerFunc 13 | ReplicaReader http.HandlerFunc 14 | FunctionProxy http.HandlerFunc 15 | ReplicaUpdater http.HandlerFunc 16 | 17 | // Optional: Update an existing function 18 | UpdateHandler http.HandlerFunc 19 | HealthHandler http.HandlerFunc 20 | } 21 | 22 | // FaaSConfig set config for HTTP handlers 23 | type FaaSConfig struct { 24 | TCPPort *int 25 | ReadTimeout time.Duration 26 | WriteTimeout time.Duration 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/realbot/faas-provider/types/requests.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package types 5 | 6 | type ScaleServiceRequest struct { 7 | ServiceName string `json:"serviceName"` 8 | Replicas uint64 `json:"replicas"` 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/realbot/faas-provider/vendor.conf: -------------------------------------------------------------------------------- 1 | github.com/gorilla/mux 24fca303ac6da784b9e8269f724ddeb0b2eea5e7 2 | github.com/gorilla/context 08b5f424b9271eedf6f9f0ce86cb9396ed337a42 3 | --------------------------------------------------------------------------------