mirror of
https://github.com/openfaas/faas.git
synced 2025-06-20 04:56:38 +00:00
Remove legacy sample function
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
2
sample-functions/ApiKeyProtected/.gitignore
vendored
2
sample-functions/ApiKeyProtected/.gitignore
vendored
@ -1,2 +0,0 @@
|
|||||||
ApiKeyProtected
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
FROM golang:1.9.4-alpine as builder
|
|
||||||
|
|
||||||
MAINTAINER alex@openfaas.com
|
|
||||||
ENTRYPOINT []
|
|
||||||
|
|
||||||
RUN apk --no-cache add make curl \
|
|
||||||
&& curl -sL https://github.com/openfaas/faas/releases/download/0.7.1/fwatchdog > /usr/bin/fwatchdog \
|
|
||||||
&& chmod +x /usr/bin/fwatchdog
|
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/openfaas/faas/sample-functions/ApiKeyProtected
|
|
||||||
|
|
||||||
COPY handler.go .
|
|
||||||
# COPY vendor vendor
|
|
||||||
|
|
||||||
RUN go install
|
|
||||||
|
|
||||||
FROM alpine:3.6
|
|
||||||
|
|
||||||
# Needed to reach the hub
|
|
||||||
RUN apk --no-cache add ca-certificates
|
|
||||||
|
|
||||||
COPY --from=builder /usr/bin/fwatchdog /usr/bin/fwatchdog
|
|
||||||
COPY --from=builder /go/bin/ApiKeyProtected /usr/bin/ApiKeyProtected
|
|
||||||
ENV fprocess "/usr/bin/ApiKeyProtected"
|
|
||||||
|
|
||||||
CMD ["/usr/bin/fwatchdog"]
|
|
@ -1,6 +0,0 @@
|
|||||||
### Api-Key-Protected sample
|
|
||||||
|
|
||||||
To use this sample provide an env variable for the container/service in `secret_api_key`.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/openfaas/faas/watchdog/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func handle(header http.Header, body []byte) {
|
|
||||||
key := header.Get("X-Api-Key")
|
|
||||||
if key == os.Getenv("secret_api_key") {
|
|
||||||
fmt.Println("Unlocked the function!")
|
|
||||||
} else {
|
|
||||||
fmt.Println("Access denied!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
bytes, _ := ioutil.ReadAll(os.Stdin)
|
|
||||||
req, err := types.UnmarshalRequest(bytes)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
handle(req.Header, req.Body.Raw)
|
|
||||||
}
|
|
@ -19,14 +19,13 @@ Here is a list of some of the sample functions included this repository.
|
|||||||
|
|
||||||
| Name | Details |
|
| Name | Details |
|
||||||
|------------------------|----------------------------------------- |
|
|------------------------|----------------------------------------- |
|
||||||
| AlpineFunction | BusyBox - a useful base image with busybox utilities pre-installed |
|
| AlpineFunction | BusyBox - a useful base image with busybox utilities pre-installed |
|
||||||
| ApiKeyProtected | Example in Golang showing how to read X-Api-Key header |
|
| ApiKeyProtected-Secrets | Example in Golang showing how to read a secret from a HTTP header and validate with a Swarm/Kubernetes secret |
|
||||||
| CaptainsIntent | Alexa skill - find the count of Docker Captains |
|
| CaptainsIntent | Alexa skill - find the count of Docker Captains |
|
||||||
| ChangeColorIntent | Alexa skill - change the colour of IoT-connected lights |
|
| ChangeColorIntent | Alexa skill - change the colour of IoT-connected lights |
|
||||||
| echo | Uses `cat` from BusyBox to provide an echo function |
|
| echo | Uses `cat` from BusyBox to provide an echo function |
|
||||||
| DockerHubStats | Golang function gives the count of repos a user has on the Docker hub |
|
| DockerHubStats | Golang function gives the count of repos a user has on the Docker hub |
|
||||||
| HostnameIntent | Prints the hostname of a container |
|
| HostnameIntent | Prints the hostname of a container |
|
||||||
| NodeInfo | Node.js - gives CPU/network info on the current container |
|
| NodeInfo | Node.js - gives CPU/network info on the current container |
|
||||||
| WebhookStash | Golang function provides way to capture webhooks - JSON/text/binary are all OK |
|
| WebhookStash | Golang function provides way to capture webhooks - JSON/text/binary are all OK |
|
||||||
| WordCountFunction | BusyBox `wc` is exposed as a function / service through FaaS |
|
| WordCountFunction | BusyBox `wc` is exposed as a function / service through FaaS |
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user