Skip to content

Commit

Permalink
New changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharpz7 committed Dec 28, 2020
1 parent d06b44e commit 9ef3a95
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.1.1
VERSION=0.1.2
82 changes: 41 additions & 41 deletions sharpcd.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
version: 1

tasks:
# basic_task:
# name: Basic
# type: docker
# sharpurl: https://localhost:5666
# giturl: https://raw.githubusercontent.com/Sharpz7/
# compose: /sharpcd/master/testing/basic.yml
basic_task:
name: Basic
type: docker
sharpurl: https://localhost:5666
giturl: https://raw.githubusercontent.com/Sharpz7/
compose: /sharpcd/master/testing/basic.yml

# env_task:
# name: Enviroment Test Fail
# type: docker
# envfile: .env
# sharpurl: https://localhost:5666
# giturl: https://raw.githubusercontent.com/Sharpz7/
# compose: /sharpcd/master/testing/env.yml
env_task:
name: Enviroment Test Fail
type: docker
envfile: .env
sharpurl: https://localhost:5666
giturl: https://raw.githubusercontent.com/Sharpz7/
compose: /sharpcd/master/testing/env.yml

network_task:
name: Network Test Fail
external_task:
name: External Docker Parts
type: docker
sharpurl: https://localhost:5666
giturl: https://raw.githubusercontent.com/Sharpz7/
compose: /sharpcd/master/testing/network.yml
compose: /sharpcd/master/testing/external.yml

# env_task2:
# name: Enviroment Test Pass
# type: docker
# envfile: ./testing/.env
# sharpurl: https://localhost:5666
# giturl: https://raw.githubusercontent.com/Sharpz7/
# compose: /sharpcd/master/testing/env.yml
env_task2:
name: Enviroment Test Pass
type: docker
envfile: ./testing/.env
sharpurl: https://localhost:5666
giturl: https://raw.githubusercontent.com/Sharpz7/
compose: /sharpcd/master/testing/env.yml

# file_task:
# name: No Compose File
# type: docker
# sharpurl: https://localhost:5666
# giturl: https://raw.githubusercontent.com/Sharpz7/
# compose: /sharpcd/master/testing/basic
file_task:
name: No Compose File
type: docker
sharpurl: https://localhost:5666
giturl: https://raw.githubusercontent.com/Sharpz7/
compose: /sharpcd/master/testing/basic

# Delayed_task:
# name: Delayed stop
# type: docker
# sharpurl: https://localhost:5666
# giturl: https://raw.githubusercontent.com/Sharpz7/
# compose: /sharpcd/master/testing/delayed.yml
Delayed_task:
name: Delayed stop
type: docker
sharpurl: https://localhost:5666
giturl: https://raw.githubusercontent.com/Sharpz7/
compose: /sharpcd/master/testing/delayed.yml

# Restart_task:
# name: Test Log exit
# type: docker
# sharpurl: https://localhost:5666
# giturl: https://raw.githubusercontent.com/Sharpz7/
# compose: /sharpcd/master/testing/restart.yml
Restart_task:
name: Test Log exit
type: docker
sharpurl: https://localhost:5666
giturl: https://raw.githubusercontent.com/Sharpz7/
compose: /sharpcd/master/testing/restart.yml
6 changes: 3 additions & 3 deletions sharpdev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ scripts:
sudo ./internal/sharpcd server
client: |
sudo docker-compose -f "./testing/external.yml" down &&
sudo docker volume rm memes &&
sudo docker network rm memes &&
sudo docker-compose -f "./internal/sharpcd-data/docker/external_task/docker-compose.yml" down &&
$(sudo docker volume rm memes) > /dev/null 2>&1 || true &&
$(sudo docker network rm memes) > /dev/null 2>&1 || true &&
sharpdev build &&
./internal/sharpcd --secret Secret123
Expand Down
4 changes: 3 additions & 1 deletion src/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func postCommChecks(t task, id string) error {
return errors.New("Bad API")
}

time.Sleep(1 * time.Second)

job := resp.Job

stopped := job.Status == jobStatus.Stopped && runningTriggered
Expand Down Expand Up @@ -179,7 +181,7 @@ func postCommChecks(t task, id string) error {
return errors.New("Bad Task")
}

if counter > 15 {
if counter > 5 {
fmt.Println("Task has started Properly!")
return nil
}
Expand Down
30 changes: 20 additions & 10 deletions src/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,27 @@ func (job *taskJob) buildCommand(args ...string) {
handleAPI(err, job, errMsg)
} else if strings.Contains(string(out), "manually using `") {

// Find Docker Command
re := regexp.MustCompile("`(.*)`")
command := strings.ReplaceAll(string(re.Find(out)), "`", "")
commands := strings.Split(command, " ")

// Create Missing Element
cmd := exec.Command(commands[0], commands[1:]...)
for {
cmd := exec.Command("docker-compose", args...)
out, err = cmd.CombinedOutput()

if strings.Contains(string(out), "manually using `") {
// Find Docker Command
re := regexp.MustCompile("`(.*)`")
command := strings.ReplaceAll(string(re.Find(out)), "`", "")
commands := strings.Split(command, " ")

// Create Missing Element
cmd := exec.Command(commands[0], commands[1:]...)

// Handle Errors
out, err := cmd.CombinedOutput()
handleAPI(err, job, string(out))
} else {
break
}
}

// Handle Errors
out, err := cmd.CombinedOutput()
handleAPI(err, job, string(out))
} else {
errMsg = string(out)
handleAPI(err, job, errMsg)
Expand Down
2 changes: 1 addition & 1 deletion testing/delayed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version: '3'
services:
hello_world:
image: ubuntu
command: ["/bin/sh", "-c", "echo Hello && sleep 4"]
command: ["/bin/sh", "-c", "echo Hello && sleep 1"]

0 comments on commit 9ef3a95

Please sign in to comment.