Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e7065c7
Showing
24 changed files
with
1,807 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
bin | |||
tmp | |||
.vscode | |||
report.xml | |||
debug | |||
.idea/ | |||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,38 @@ | |||
language: go | |||
matrix: | |||
include: | |||
- go: 1.x | |||
env: LATEST=true | |||
- go: 1.10.x | |||
- go: 1.11.x | |||
- go: 1.12.x | |||
- go: tip | |||
allow_failures: | |||
- go: tip | |||
|
|||
before_install: | |||
- go get github.com/mitchellh/gox | |||
|
|||
install: | |||
- export GO111MODULE=on | |||
- go get -t -v ./... | |||
|
|||
script: | |||
- go test -v -race ./... | |||
- if [ "${LATEST}" = "true" ]; then gox -ldflags "-s -w -X main.Version=$TRAVIS_TAG" -os="linux darwin" -arch="386 amd64" -osarch="linux/arm" -output="monday-{{.OS}}-{{.Arch}}" -verbose ./...; fi | |||
|
|||
deploy: | |||
provider: releases | |||
skip_cleanup: true | |||
api_key: | |||
secure: $GITHUB_TOKEN | |||
file: | |||
- monday-darwin-386 | |||
- monday-darwin-amd64 | |||
- monday-linux-386 | |||
- monday-linux-amd64 | |||
- monday-linux-arm | |||
on: | |||
repo: eko/monday | |||
tags: true | |||
condition: $LATEST = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
Copyright (c) 2019 Vincent Composieux <github@composieux.fr> | |||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy | |||
of this software and associated documentation files (the "Software"), to deal | |||
in the Software without restriction, including without limitation the rights | |||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
copies of the Software, and to permit persons to whom the Software is | |||
furnished to do so, subject to the following conditions: | |||
|
|||
The above copyright notice and this permission notice shall be included in all | |||
copies or substantial portions of the Software. | |||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,224 @@ | |||
# Monday | |||
|
|||
[![TravisBuildStatus](https://api.travis-ci.org/eko/monday.svg?branch=master)](https://travis-ci.org/eko/monday) | |||
[![GoDoc](https://godoc.org/github.com/eko/monday?status.png)](https://godoc.org/github.com/eko/monday) | |||
[![GoReportCard](https://goreportcard.com/badge/github.com/eko/monday)](https://goreportcard.com/report/github.com/eko/monday) | |||
|
|||
|
|||
Your new microservice local environment friend. This CLI tool allows you to define a configuration to do (or mix) both local applications (Go, NodeJS, Rust or others) and also forward other applications over Kubernetes in case you don't want to run them locally. | |||
|
|||
![Schema](https://github.com/eko/monday/blob/master/misc/schema.jpg?raw=true) | |||
|
|||
## Installation | |||
|
|||
### Download binary | |||
|
|||
You can download the latest version of the binary built for your architecture here: | |||
|
|||
* Architecture **i386** [ | |||
[Darwin](https://github.com/eko/monday/releases/latest/download/monday-darwin-386) / | |||
[Linux](https://github.com/eko/monday/releases/latest/download/monday-linux-386) | |||
] | |||
* Architecture **amd64** [ | |||
[Darwin](https://github.com/eko/monday/releases/latest/download/monday-darwin-amd64) / | |||
[Linux](https://github.com/eko/monday/releases/latest/download/monday-linux-amd64) | |||
] | |||
* Architecture **arm** [ | |||
[Linux](https://github.com/eko/it/releases/latest/download/monday-linux-arm) | |||
] | |||
|
|||
### From sources | |||
|
|||
Optionally, you can download and build it from the sources. You have to retrieve the project sources by using one of the following way: | |||
```bash | |||
$ go get -u github.com/eko/monday | |||
# or | |||
$ git clone https://github.com/eko/monday.git | |||
``` | |||
|
|||
Install the needed vendors: | |||
|
|||
``` | |||
$ GO111MODULE=on go mod vendor | |||
``` | |||
|
|||
Then, build the binary (here, an example to run on Raspberry PI ARM architecture): | |||
```bash | |||
$ go build -o monday . | |||
``` | |||
|
|||
## Usage | |||
|
|||
First, you have to initialize monday and edit your configuration file (you have a [configuration example file here](https://raw.githubusercontent.com/eko/monday/example.yaml)). | |||
Run the following command and edit the `~/monday.yaml` configuration file just created for you: | |||
|
|||
⚠️ Warn: Because Monday tries to be intelligent, manages hosts for you and try to guess you local environment variables, I suggest to run it using the following alias: | |||
|
|||
```bash | |||
alias monday='sudo -E -u $USER monday' | |||
``` | |||
|
|||
```bash | |||
$ monday init | |||
``` | |||
|
|||
Once your configuration file is ready, you can simply run Monday: | |||
|
|||
```bash | |||
$ monday | |||
``` | |||
|
|||
When you want to edit your configuration again, simply run this command to open it in your favorite editor: | |||
|
|||
```bash | |||
$ monday edit | |||
``` | |||
|
|||
## Configuration example | |||
|
|||
Here is a configuration example that allows you to see all the things you could do with Monday: | |||
|
|||
```yaml | |||
# Settings | |||
|
|||
gopath: /Users/vincent/golang # Optional, default to user's $GOPATH env var | |||
|
|||
# Local applications | |||
|
|||
<: &graphql-local | |||
name: graphql | |||
path: github.com/acme/graphql # Will find in GOPATH (as executable is "go") | |||
executable: go | |||
args: | |||
- run | |||
- cmd/main.go | |||
|
|||
<: &grpc-api-local | |||
name: grpc-api | |||
path: github.com/acme/grpc-api # Will find in GOPATH (as executable is "go") | |||
executable: go | |||
args: | |||
- run | |||
- main.go | |||
|
|||
<: &search-api-local | |||
name: search-api | |||
path: github.com/acme/search-api # Will find in GOPATH (as executable is "go") | |||
executable: go | |||
args: | |||
- run | |||
- main.go | |||
|
|||
<: &pub-front-local | |||
name: pub-front | |||
path: /Users/vincent/dev/pub-front | |||
executable: npm | |||
args: | |||
- run | |||
- start | |||
|
|||
<: &elasticsearch-local | |||
name: elasticsearch | |||
path: /Users/vincent/dev/docker | |||
executable: docker | |||
args: | |||
- start | |||
- -i | |||
- elastic | |||
|
|||
# Kubernetes forwards | |||
|
|||
<: &kubernetes-context preprod | |||
|
|||
<: &graphql-forward | |||
name: graphql | |||
type: kubernetes | |||
values: | |||
context: *kubernetes-context | |||
namespace: backend | |||
labels: | |||
app: graphql | |||
hostname: graphql.svc.local # Optional | |||
ports: | |||
- 8080:8000 | |||
|
|||
<: &grpc-api-forward | |||
name: grpc-api | |||
type: kubernetes | |||
values: | |||
context: *kubernetes-context | |||
namespace: backend | |||
labels: | |||
app: grpc-api | |||
hostname: grpc-api.svc.local # Optional | |||
ports: | |||
- 8080:8080 | |||
|
|||
<: &search-api-forward | |||
name: search-api | |||
type: kubernetes | |||
values: | |||
context: *kubernetes-context | |||
namespace: backend | |||
labels: | |||
app: search-api | |||
hostname: search-api.svc.local # Optional | |||
ports: | |||
- 8080:8080 | |||
|
|||
<: &pub-front-forward | |||
name: pub-front | |||
type: kubernetes | |||
values: | |||
context: *kubernetes-context | |||
namespace: frontend | |||
labels: | |||
app: pub-front | |||
hostname: pub-front.svc.local # Optional | |||
ports: | |||
- 8080:8080 | |||
|
|||
<: &composieux-fr | |||
name: composieux-fr | |||
type: ssh | |||
values: | |||
remote: vincent@composieux.fr # SSH <user>@<hostname> | |||
hostname: composieux.fr.svc.local # Optional | |||
ports: | |||
- 8080:80 | |||
|
|||
# Projects | |||
|
|||
projects: | |||
- name: full | |||
local: | |||
- *graphql-local | |||
- *grpc-api-local | |||
- *search-api-local | |||
- *pub-front-local | |||
- *elasticsearch-local | |||
|
|||
- name: graphql | |||
local: | |||
- *graphql-local | |||
forward: | |||
- *grpc-api-forward | |||
- *search-api-forward | |||
- *pub-front-forward | |||
|
|||
- name: forward-only | |||
forward: | |||
- *graphql-forward | |||
- *grpc-api-forward | |||
- *search-api-forward | |||
- *pub-front-forward | |||
|
|||
``` | |||
|
|||
## Run tests | |||
|
|||
Test suite can be run with: | |||
|
|||
```bash | |||
$ go test -v ./... | |||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,30 @@ | |||
package main | |||
|
|||
import ( | |||
"fmt" | |||
"os/exec" | |||
|
|||
"github.com/eko/monday/internal/config" | |||
"github.com/spf13/cobra" | |||
) | |||
|
|||
var editCmd = &cobra.Command{ | |||
Use: "edit", | |||
Short: "This command allows you to open the configuration file in your default editor", | |||
Long: `For more information about the configuration, see the "example.yaml" file available | |||
in the source code repository.`, | |||
Run: func(cmd *cobra.Command, args []string) { | |||
err := config.CheckConfigFileExists() | |||
if err != nil { | |||
fmt.Printf("❌ %v\n", err) | |||
return | |||
} | |||
|
|||
command := exec.Command("open", config.Filepath) | |||
|
|||
if err := command.Start(); err != nil { | |||
fmt.Printf("❌ Cannot run the 'open' command to edit config file: %v\n", err) | |||
return | |||
} | |||
}, | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
package main | |||
|
|||
import ( | |||
"fmt" | |||
"os" | |||
"os/exec" | |||
|
|||
"github.com/spf13/cobra" | |||
"github.com/eko/monday/internal/config" | |||
) | |||
|
|||
var initCmd = &cobra.Command{ | |||
Use: "init", | |||
Short: "This command initializes a new configuration file and opens it in your favorite editor", | |||
Long: `For more information about the configuration, see the "example.yaml" file available | |||
in the source code repository.`, | |||
Run: func(cmd *cobra.Command, args []string) { | |||
if _, err := os.Stat(config.Filepath); os.IsNotExist(err) { | |||
f, err := os.Create(config.Filepath) | |||
f.Close() | |||
if err != nil { | |||
fmt.Printf("❌ Cannot create config file in your home directory: %v\n", err) | |||
return | |||
} | |||
|
|||
command := exec.Command("open", config.Filepath) | |||
|
|||
if err := command.Start(); err != nil { | |||
fmt.Printf("❌ Cannot run the 'open' command to edit config file: %v\n", err) | |||
return | |||
} | |||
} else { | |||
fmt.Println("❌ You already have a configuration file. Please use 'edit' command") | |||
return | |||
} | |||
}, | |||
} |
Oops, something went wrong.