-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add execution container * Remove deprecated function call * Add support for slice script * Add support for Git authentication * Outsource image tags * Add first MVP of Docker executor
- Loading branch information
1 parent
f409694
commit 85f638d
Showing
8 changed files
with
234 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package config | ||
|
||
const ( | ||
CloneContainerImage = "alpine/git:latest" | ||
ResultContainerImage = "alpine:latest" | ||
SharedVolumeName = "shared" | ||
) |
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,44 @@ | ||
package docker | ||
|
||
import ( | ||
"context" | ||
"github.com/Mtze/HadesCI/hadesScheduler/config" | ||
"github.com/docker/docker/api/types" | ||
"github.com/docker/docker/api/types/container" | ||
"github.com/docker/docker/api/types/mount" | ||
"github.com/docker/docker/client" | ||
"github.com/docker/docker/pkg/stdcopy" | ||
"os" | ||
) | ||
|
||
var defaultHostConfig = container.HostConfig{ | ||
Mounts: []mount.Mount{ | ||
{ | ||
Type: mount.TypeVolume, | ||
Source: sharedVolumeName, | ||
Source: config.SharedVolumeName, | ||
Target: "/shared", | ||
}, | ||
}, | ||
AutoRemove: true, | ||
} | ||
|
||
func writeContainerLogsToFile(ctx context.Context, client *client.Client, containerID string, logFilePath string) error { | ||
out, err := os.Create(logFilePath) | ||
if err != nil { | ||
return err | ||
} | ||
defer out.Close() | ||
|
||
logReader, err := client.ContainerLogs(ctx, containerID, types.ContainerLogsOptions{ | ||
ShowStdout: true, | ||
ShowStderr: true, | ||
Timestamps: true, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
defer logReader.Close() | ||
|
||
_, err = stdcopy.StdCopy(out, out, logReader) | ||
return err | ||
} |
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package docker | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
) | ||
|
||
func writeBashScriptToFile(bashScriptLines ...string) (string, error) { | ||
bashScriptContent := strings.Join(bashScriptLines, "\n") | ||
tmpFile, err := os.CreateTemp("", "bash-script-*.sh") | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
_, err = tmpFile.Write([]byte(bashScriptContent)) | ||
if err != nil { | ||
tmpFile.Close() | ||
return "", err | ||
} | ||
|
||
path := tmpFile.Name() | ||
tmpFile.Close() | ||
return path, nil | ||
} |
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
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
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