-
Notifications
You must be signed in to change notification settings - Fork 0
Cli #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Cli #1
Changes from all commits
0fd1655
8e2cc6f
bd8c3d4
7dadf90
9ed0e8d
7a19a3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
.PHONY: test | ||
|
||
all: | clean deps gen_protobuf build gen_mocks test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: missing Phony on most the targets |
||
|
||
clean: | ||
@rm -rf ./gen/* | ||
@rm -rf ./test/cli/mocks/* | ||
@rm -rf ./test/common/mocks/* | ||
|
||
deps: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use golang's standard dependency manager? e.g dep or vgo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have used govendor in the past, and simply did it this way because it was faster for getting the prototype going. I am all for dependency management :-) |
||
@echo syncing dependencies... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would generally recommend to vendor the dependencies, creates less risk that upstream changes will break things. We generally use dep (https://github.com/golang/dep), but vgo (https://github.com/golang/go/wiki/vgo) is the current hotness, and there are a few other tools that are all good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree. I have used Govendor in the past, but I wanted to keep it simple for the prototype. I'll check out vgo. |
||
@go get github.com/onsi/ginkgo | ||
@go get github.com/onsi/gomega | ||
@go get github.com/vektra/mockery/.../ | ||
@go get github.com/stretchr/testify/mock | ||
@go get -u google.golang.org/grpc | ||
@go get -u github.com/golang/protobuf/protoc-gen-go | ||
|
||
build: build_cli | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .PHONY for build targets? |
||
|
||
build_cli: | ||
@echo building cli... | ||
@go build -o go-scheduler-cli ./cmd/go-scheduler-cli | ||
@chmod +x go-scheduler-cli | ||
|
||
gen_mocks: | ||
@echo generating mocks... | ||
@${GOPATH}/bin/mockery -all -dir pkg/cli -output test/cli/mocks -case=underscore | ||
@${GOPATH}/bin/mockery -all -dir pkg/common -output test/common/mocks -case=underscore | ||
@${GOPATH}/bin/mockery -all -dir pkg/master -output test/master/mocks -case=underscore | ||
@${GOPATH}/bin/mockery -all -dir gen/protobuf/master -output test/master/mocks -case=underscore | ||
|
||
gen_protobuf: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not reproducible - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate? I am not quite following. Are you referring to this line under deps: |
||
@echo generating protobuf APIs... | ||
@command -v protoc >/dev/null 2>&1 || { echo >&2 "protoc is not installed. "; exit 1; } | ||
@protoc --go_out=plugins=grpc,paths=source_relative:./gen ./protobuf/master/master.proto | ||
|
||
test: | ||
@echo running tests... | ||
@${GOPATH}/bin/ginkgo -r ./test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,47 @@ | ||
# go-scheduler | ||
This is a distributed job scheduler for linux systems built in Go. | ||
This is a distributed job scheduler for linux systems built in Go. It can run arbitrary docker images on a cluster of computers. | ||
|
||
# Install | ||
|
||
## Get the package | ||
`go get github.com/kmacmcfarlane/go-scheduler` | ||
|
||
## Build the project | ||
`make` | ||
|
||
## Generate Certificates with EasyRSA | ||
The cluster uses x509 certificates to authenticate the client, master, and node applications. | ||
|
||
# CLI | ||
The go-scheduler CLI client allows you to control work run on the cluster. | ||
|
||
## Install Client Certificate | ||
The client certificate is used to authenticate with your cluster. The certificate must have file permission 600. | ||
|
||
`mkdir ~/.go-scheduler` | ||
`cp ~/Downloads/client.crt ~/.go-scheduler/client.crt` | ||
`chmod 600 ~/.go-scheduler/client.crt` | ||
|
||
## Start a Job | ||
|
||
`go-scheduler-cli start --image redis --name redisCache --master 192.168.1.80` | ||
|
||
## Stop a Job | ||
|
||
`go-scheduler-cli stop --name redisCache --master 192.168.1.80` | ||
|
||
## Query Job Status | ||
|
||
`go-scheduler-cli query --name redisCache --master 192.168.1.80` | ||
|
||
## Stream Log Output | ||
|
||
`go-scheduler-cli log --name redisCache --master 192.168.1.80` | ||
|
||
## Status Codes | ||
go-scheduler-cli returns the following status codes: | ||
|
||
0: success | ||
1: error parsing command-line arguments | ||
2: error parsing command-line arguments | ||
3: application error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We recommend to follow these guidelines for consistency: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't seen this before. I will give it a read. |
||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/kmacmcfarlane/go-scheduler/internal/grpc" | ||
"github.com/kmacmcfarlane/go-scheduler/pkg/cli" | ||
"github.com/kmacmcfarlane/go-scheduler/pkg/common" | ||
"os" | ||
) | ||
|
||
func main() { | ||
|
||
ctx := context.Background() | ||
|
||
logger := common.NewConsoleLogger() | ||
|
||
clientFactory := grpc.NewMasterClientFactory() | ||
|
||
clientService := cli.NewClientService(ctx, clientFactory, logger) | ||
|
||
commandParser := cli.NewCommandParser(clientService, logger) | ||
|
||
// Parse and execute Command | ||
err := commandParser.Parse(os.Args) | ||
|
||
if nil != err { | ||
fmt.Fprintln(os.Stderr, err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
os.Exit(0) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gofmt will help with formatting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to remove binary files from the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.