Skip to content

Commit

Permalink
Merge pull request #16 from Sharpz7/dev
Browse files Browse the repository at this point in the history
Updated to V3.3:
  • Loading branch information
Sharpz7 authored Nov 7, 2021
2 parents c437342 + 3a9ed95 commit 49c70ad
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=3.2
VERSION=3.3
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ tasks:
On linux, just run:
```console
╭─adam@box ~/
╰─➤ sudo curl -s -L https://github.com/Sharpz7/sharpcd/releases/download/3.2/install.sh | sudo bash
╰─➤ sudo curl -s -L https://github.com/Sharpz7/sharpcd/releases/download/3.3/install.sh | sudo bash
```

Or for just the client:
```console
╭─adam@box ~/
╰─➤ sudo curl -s -L https://github.com/Sharpz7/sharpcd/releases/download/3.2/install.sh | sudo bash -s client
╰─➤ sudo curl -s -L https://github.com/Sharpz7/sharpcd/releases/download/3.3/install.sh | sudo bash -s client
```

## Command Options
Expand Down
5 changes: 4 additions & 1 deletion sharpdev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ scripts:
traklist: |
sharpdev trak list local
traklogs: |
sharpdev trak logs local $_ARG1
filter: ./internal/sharpcd addfilter https://raw.githubusercontent.com/Sharpz7/
remove: ./internal/sharpcd removefilter https://raw.githubusercontent.com/Sharpz7/
token: ./internal/sharpcd changetoken $_ARG1

alljobsd: curl -k -X POST -d SECRETD https://localhost:5666/api/jobs
alljobs: curl -k -X POST -d SECRET https://173.212.252.82:5666/api/jobs
alljobs: curl -k -X POST -d SECRET https://173.312.252.82:5666/api/jobs
logsfeed: curl -k -X POST -d SECRETD https://localhost:5666/api/logsfeed/$_ARG1
job: curl -k -X POST -d SECRETD https://localhost:5666/api/job/$_ARG1
logs: curl -k -X POST -d SECRETD https://localhost:5666/api/logs/$_ARG1
Expand Down
2 changes: 1 addition & 1 deletion src/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/gorilla/websocket"
)

var sharpCDVersion = "3.2"
var sharpCDVersion = "3.3"

type statusCodes struct {
NotPostMethod int
Expand Down
32 changes: 31 additions & 1 deletion src/trak.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,43 @@ func trak() {
liveFeed()
case "list":
listJobs()
case "logs":
apiLog()
default:
flag.Usage()
handle(errors.New(""), "No valid trak arg was given")
}

}

// Get log file from job
func apiLog() {
if len(flag.Args()) < 3 {
flag.Usage()
handle(errors.New(""), "No valid location was given")
}

var location = flag.Args()[2]
var jobID = flag.Args()[3]

// Get sharpcd file
f, err := ioutil.ReadFile("./sharpcd.yml")
var con config
err = yaml.Unmarshal(f, &con)
handle(err, "Failed to read and extract sharpcd.yml")

urlJobs := con.Trak[location] + "/api/logs/" + jobID

// Insert needed data
secret := getSec()

apiOutput, _ := getAPIOutput(urlJobs, secret)
logMsg := apiOutput.Message

fmt.Println("\nLogs from " + con.Trak[location] + ":\n")
fmt.Println(logMsg + "\n")
}

// Lists all jobs running on server
func listJobs() {
if len(flag.Args()) < 3 {
Expand Down Expand Up @@ -110,7 +140,7 @@ func liveFeed() {

// Only needed for single job requests
if trakArg == trakOne {
if len(flag.Args()) < 3 {
if len(flag.Args()) < 4 {
flag.Usage()
handle(errors.New(""), "No valid Job ID was given")
}
Expand Down

0 comments on commit 49c70ad

Please sign in to comment.