Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-alpha.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh committed Mar 27, 2018
2 parents 4c440c0 + 7750a26 commit 20a7c08
Show file tree
Hide file tree
Showing 51 changed files with 2,114 additions and 852 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED] - 0000-00-00

## [1.0.0-alpha.12] - 2018-03-27
### Added
- [CLI] `ps` to support container status
- -a flag for logs, ps, env and run command
- commit sha in build struct for git based app
- Docker build logs with websocket on AWS
- Adding cluster-instance-type and controller-instance-type in `datacol init`
- AWS elasticsearch support
- Websocket connection for streaming logs and Running one-off commands
- Added `--ref` flag into deploy cmd
- Proxy support through bastion Host
### Fixed
- CLI improvements
- [CLI] Bump default version of GCP cluster to `1.7.14-gke.1`
- [API] Merging app's domain individually
- [CLI] Respect `STACK` env variable to ditermine stack
- [GCP] Ingress should have Path: '/*' to match sub-resources
- Embedding Provider for `datacol login`
- Procfile support for Codecommit based app

## [1.0.0-alpha.11] - 2018-03-02
### Added
Expand Down
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=1.0.0-alpha.10
version=1.0.0-alpha.12
MODEL_PROTO_DIR=./api/models
SERVICE_PROTO_DIR=./api/controller
VEDNOR_GOOGLE_APIS=./vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
Expand Down Expand Up @@ -30,6 +30,10 @@ proto:
go install -v ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go install -v ./vendor/github.com/go-swagger/go-swagger/cmd/swagger

templates:
gsutil cp cmd/provider/aws/kubernetes-cluster.template gs://datacol-dev/
gsutil acl ch -u AllUsers:R gs://datacol-dev/kubernetes-cluster.template

gentest:
protoc -I $(SERVICE_PROTO_DIR) $(PROTOC_INCLUDE_DIR) \
--go_out=plugins=grpc:$(SERVICE_PROTO_DIR) \
Expand Down
326 changes: 119 additions & 207 deletions api/controller/services.pb.go

Large diffs are not rendered by default.

76 changes: 0 additions & 76 deletions api/controller/services.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions api/controller/services.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ message AuthResponse {
string name = 2;
string project = 3;
string region = 4;
string provider = 5;
}

message CreateBuildRequest {
Expand Down Expand Up @@ -100,12 +101,6 @@ message CmdResponse {
string stdErr = 4;
}

message BuildLogStreamReq {
string id = 1;
bool follow = 2;
google.protobuf.Duration since = 3;
}

message LogStreamReq {
string name = 1;
bool follow = 2;
Expand Down Expand Up @@ -214,12 +209,6 @@ service ProviderService {
};
}

rpc BuildLogsStream(BuildLogStreamReq) returns (stream StreamMsg) {
option (google.api.http) = {
get: "/v1/builds/{id}/logs/stream"
};
}

rpc EnvironmentGet(AppRequest) returns (models.EnvConfig) {
option (google.api.http) = {
get: "/v1/env/{name}"
Expand Down
53 changes: 6 additions & 47 deletions api/controller/services.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,53 +302,6 @@
]
}
},
"/v1/builds/{id}/logs/stream": {
"get": {
"operationId": "BuildLogsStream",
"responses": {
"200": {
"description": "(streaming responses)",
"schema": {
"$ref": "#/definitions/controllerStreamMsg"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "follow",
"in": "query",
"required": false,
"type": "boolean",
"format": "boolean"
},
{
"name": "since.seconds",
"description": "Signed seconds of the span of time. Must be from -315,576,000,000\nto +315,576,000,000 inclusive.",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "since.nanos",
"description": "Signed fractions of a second at nanosecond resolution of the span\nof time. Durations less than one second are represented with a 0\n`seconds` field and a positive or negative `nanos` field. For durations\nof one second or more, a non-zero value for the `nanos` field must be\nof the same sign as the `seconds` field. Must be from -999,999,999\nto +999,999,999 inclusive.",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
}
],
"tags": [
"ProviderService"
]
}
},
"/v1/builds/{name}": {
"get": {
"operationId": "BuildList",
Expand Down Expand Up @@ -883,6 +836,9 @@
},
"region": {
"type": "string"
},
"provider": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -1026,6 +982,9 @@
"procfile": {
"type": "string",
"format": "byte"
},
"version": {
"type": "string"
}
}
},
Expand Down
58 changes: 58 additions & 0 deletions api/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import (
"errors"
"fmt"
"io"
"net/http"
"os"
"strings"
"sync"

log "github.com/Sirupsen/logrus"
"golang.org/x/net/context"
"golang.org/x/net/websocket"
"google.golang.org/grpc/metadata"
)

Expand Down Expand Up @@ -67,6 +71,36 @@ func checkHttpAuthorization(value, expected string) bool {
return pair[1] == expected
}

func checkAPIKey(r *http.Request) bool {
if os.Getenv("DATACOL_API_KEY") == "" {
return true
}

auth := r.Header.Get("Authorization")

if auth == "" {
return false
}

if !strings.HasPrefix(auth, "Basic ") {
return false
}

c, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(auth, "Basic "))

if err != nil {
return false
}

parts := strings.SplitN(string(c), ":", 2)

if len(parts) != 2 || parts[1] != os.Getenv("DATACOL_API_KEY") {
return false
}

return true
}

func writeToFd(fd io.Writer, data []byte) error {
w := 0
n := len(data)
Expand All @@ -81,3 +115,27 @@ func writeToFd(fd io.Writer, data []byte) error {
}
}
}

type websocketFunc func(*websocket.Conn) error

func ws(at string, handler websocketFunc) websocket.Handler {
return websocket.Handler(func(ws *websocket.Conn) {
if !checkAPIKey(ws.Request()) {
ws.Write([]byte("Unable to authenticate. Invalid ApiKey."))
return
}

err := handler(ws)

if err != nil {
log.Error(err)
ws.Write([]byte(fmt.Sprintf("ERROR: %v\n", err)))
return
}
})
}

func copyAsync(dst io.Writer, src io.Reader, wg *sync.WaitGroup) {
defer wg.Done()
io.Copy(dst, src)
}
Loading

0 comments on commit 20a7c08

Please sign in to comment.