From 56e8c5b211e8817e547831909bfcc8da24ef04c9 Mon Sep 17 00:00:00 2001
From: Alex Ellis <alexellis2@gmail.com>
Date: Mon, 5 Mar 2018 14:56:54 +0000
Subject: [PATCH] Remove legacy sample function

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
---
 sample-functions/ApiKeyProtected/.gitignore |  2 --
 sample-functions/ApiKeyProtected/Dockerfile | 26 ------------------
 sample-functions/ApiKeyProtected/README.md  |  6 -----
 sample-functions/ApiKeyProtected/handler.go | 29 ---------------------
 sample-functions/README.md                  | 21 +++++++--------
 5 files changed, 10 insertions(+), 74 deletions(-)
 delete mode 100644 sample-functions/ApiKeyProtected/.gitignore
 delete mode 100644 sample-functions/ApiKeyProtected/Dockerfile
 delete mode 100644 sample-functions/ApiKeyProtected/README.md
 delete mode 100644 sample-functions/ApiKeyProtected/handler.go

diff --git a/sample-functions/ApiKeyProtected/.gitignore b/sample-functions/ApiKeyProtected/.gitignore
deleted file mode 100644
index 4e568b8f..00000000
--- a/sample-functions/ApiKeyProtected/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-ApiKeyProtected
-
diff --git a/sample-functions/ApiKeyProtected/Dockerfile b/sample-functions/ApiKeyProtected/Dockerfile
deleted file mode 100644
index 6be5d49d..00000000
--- a/sample-functions/ApiKeyProtected/Dockerfile
+++ /dev/null
@@ -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"]
diff --git a/sample-functions/ApiKeyProtected/README.md b/sample-functions/ApiKeyProtected/README.md
deleted file mode 100644
index a2a65bb1..00000000
--- a/sample-functions/ApiKeyProtected/README.md
+++ /dev/null
@@ -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.
-
diff --git a/sample-functions/ApiKeyProtected/handler.go b/sample-functions/ApiKeyProtected/handler.go
deleted file mode 100644
index 7c1f9b3d..00000000
--- a/sample-functions/ApiKeyProtected/handler.go
+++ /dev/null
@@ -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)
-}
diff --git a/sample-functions/README.md b/sample-functions/README.md
index 771812b4..abcaa4eb 100644
--- a/sample-functions/README.md
+++ b/sample-functions/README.md
@@ -19,14 +19,13 @@ Here is a list of some of the sample functions included this repository.
 
 | Name                   | Details |
 |------------------------|-----------------------------------------                          |
-| AlpineFunction         | BusyBox - a useful base image with busybox utilities pre-installed        |
-| ApiKeyProtected        | Example in Golang showing how to read X-Api-Key header |
-| CaptainsIntent         | Alexa skill - find the count of Docker Captains |
-| ChangeColorIntent      | Alexa skill - change the colour of IoT-connected lights |
-| 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 |
-| HostnameIntent         | Prints the hostname of a 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 |
-| WordCountFunction      | BusyBox `wc` is exposed as a function / service through FaaS |
-
+| AlpineFunction           | BusyBox - a useful base image with busybox utilities pre-installed        |
+| 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 |
+| ChangeColorIntent        | Alexa skill - change the colour of IoT-connected lights |
+| 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 |
+| HostnameIntent           | Prints the hostname of a 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 |
+| WordCountFunction        | BusyBox `wc` is exposed as a function / service through FaaS |
-- 
GitLab