Skip to content

Commit

Permalink
Debug code for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhjp committed Aug 25, 2023
1 parent cb2a881 commit acc2093
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugincontainer/container_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func NewContainerRunner(logger hclog.Logger, cmd *exec.Cmd, cfg *config.Containe
// Host config.
// TODO: Can we safely we drop some default capabilities?
hostConfig := &container.HostConfig{
AutoRemove: true, // Plugin containers are ephemeral.
// AutoRemove: true, // Plugin containers are ephemeral.
RestartPolicy: container.RestartPolicy{}, // Empty restart policy means never.
Runtime: cfg.Runtime, // OCI runtime.
Resources: container.Resources{
Expand Down
15 changes: 11 additions & 4 deletions plugincontainer/container_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,23 @@ func TestExamplePlugin(t *testing.T) {
id := images[0].ID
sha256 := strings.TrimPrefix(id, "sha256:")

runCmd(t, "docker", "inspect", sha256)

for name, tc := range map[string]struct {
image, sha256 string
}{
"just image": {"go-plugin-counter", ""},
"just image with tag": {"go-plugin-counter:latest", ""},
"image and sha256": {"go-plugin-counter", sha256},
"image and id": {"go-plugin-counter", id},
"just image": {"go-plugin-counter", ""},
// "just image with tag": {"go-plugin-counter:latest", ""},
// "image and sha256": {"go-plugin-counter", sha256},
// "image with tag and sha256": {"go-plugin-counter:latest", sha256},
// "image and id": {"go-plugin-counter", id},
// "image with tag and id": {"go-plugin-counter:latest", id},
} {
t.Run(name, func(t *testing.T) {
client := plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: shared.Handshake,
Plugins: shared.PluginMap,
Logger: hclog.Default().Named(t.Name()),
RunnerFunc: func(logger hclog.Logger, cmd *exec.Cmd, tmpDir string) (runner.Runner, error) {
cfg := &config.ContainerConfig{
Image: tc.image,
Expand All @@ -180,6 +185,8 @@ func TestExamplePlugin(t *testing.T) {
// Connect via RPC
rpcClient, err := client.Client()
if err != nil {
runCmd(t, "docker", "logs", client.ID())
runCmd(t, "docker", "inspect", client.ID())
t.Fatal(err)
}

Expand Down
6 changes: 3 additions & 3 deletions plugincontainer/examples/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM gcr.io/distroless/static-debian11
FROM ubuntu

COPY go-plugin-counter /bin/go-plugin-counter
COPY go-plugin-counter entrypoint.sh /bin/

ENTRYPOINT [ "/bin/go-plugin-counter" ]
ENTRYPOINT [ "/bin/sh", "/bin/entrypoint.sh" ]
2 changes: 2 additions & 0 deletions plugincontainer/examples/container/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ls /bin >&2
/bin/go-plugin-counter

0 comments on commit acc2093

Please sign in to comment.