Skip to content

Commit

Permalink
Add Control Plane API call to return the Snowplow Mini version (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
aldemirenes authored and BenFradet committed Dec 12, 2017
1 parent 9bc99b4 commit 5abb5d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
25 changes: 21 additions & 4 deletions provisioning/resources/control-plane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ package main

import (
"flag"
"github.com/BurntSushi/toml"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"

"github.com/BurntSushi/toml"
)

var configPath string
Expand All @@ -48,6 +49,7 @@ func main() {
http.HandleFunc("/local-iglu-apikey", addLocalIgluApikey)
http.HandleFunc("/credentials", changeUsernameAndPassword)
http.HandleFunc("/domain-name", addDomainName)
http.HandleFunc("/version", getSpminiVersion)
log.Fatal(http.ListenAndServe(":10000", nil))
}

Expand Down Expand Up @@ -136,11 +138,11 @@ func addExternalIgluServer(resp http.ResponseWriter, req *http.Request) {
return
}

if !isUrlReachable(uri) {
if !isURLReachable(uri) {
http.Error(resp, "Given URL is not reachable", 400)
return
}
if !isValidUuid(apikey) {
if !isValidUUID(apikey) {
http.Error(resp, "Given apikey is not valid UUID.", 400)
return
}
Expand Down Expand Up @@ -186,7 +188,7 @@ func addLocalIgluApikey(resp http.ResponseWriter, req *http.Request) {
}
igluApikey := igluApikeyArr[0]

if !isValidUuid(igluApikey) {
if !isValidUUID(igluApikey) {
http.Error(resp, "Given apikey is not valid UUID", 400)
return
}
Expand Down Expand Up @@ -296,3 +298,18 @@ func addDomainName(resp http.ResponseWriter, req *http.Request) {
http.Error(resp, "", 404)
}
}

func getSpminiVersion(resp http.ResponseWriter, req *http.Request) {
if req.Method == "GET" {
versionBytes, err := ioutil.ReadFile(config.VersionFilePath)
if err != nil {
http.Error(resp, err.Error(), 500)
return
}
versionStr := string(versionBytes)
resp.WriteHeader(http.StatusOK)
io.WriteString(resp, versionStr)
} else {
http.Error(resp, "", 404)
}
}
6 changes: 6 additions & 0 deletions provisioning/roles/sp_mini_3_setup_apps/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
src: "{{playbook_dir}}/resources/control-plane/snowplow-mini-control-plane-api"
dest: "{{executables_dir}}"

- name: Copy VERSION file to /home/ubuntu/snowplow for Control API
become: yes
synchronize:
src: "{{playbook_dir}}/../VERSION"
dest: "{{main_dir}}"

- name: Check Kinesis Packages
stat:
path: "{{staging_dir}}/{{kinesis_package}}"
Expand Down

0 comments on commit 5abb5d2

Please sign in to comment.