From 03befb04dafa050a944a295b06a41653924e6aff Mon Sep 17 00:00:00 2001 From: davidmdm Date: Thu, 27 May 2021 10:15:16 -0400 Subject: [PATCH] updated readme --- README.md | 18 ++++++++++++------ src/internal/context.go | 1 + src/internal/docker/cli.go | 15 +++++++++------ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e8adf85..47d124e 100644 --- a/README.md +++ b/README.md @@ -138,10 +138,16 @@ contexts: # Ideas/questions - yey! -- Do we really need a default/current context (instead of always specifying) - Do we really need to names containers with tag? -- Simplify context file format - - .yeyrc - - Move base to top level? -- Default user.yaml could be just shared.yaml initially all commented out -- No different naming (user.yaml/shared.yaml), just `.yeyrc` or `.yey.yaml` + +- yey start flags: --rm && --reset + +- yey user support??? can we run our containers as not root via context config or otherwise? SPIKE + +- Currently we have image support in contextFile, how about Dockerfile support? BOOM + +- yey rm [contextName/prompt] -> removes containers with prefix yey-pathHash-contextName-\* + + - rm --all remove all contexts + +- yey tidy -> removes containers from all context names that are not references: yey-pathHash-contextNames-notusedContextHash diff --git a/src/internal/context.go b/src/internal/context.go index 85e28af..9a32f9a 100644 --- a/src/internal/context.go +++ b/src/internal/context.go @@ -11,6 +11,7 @@ import ( // Context represents execution configuration for some docker container type Context struct { Name string `yaml:",omitempty"` + Remove bool Image string Env map[string]string Mounts map[string]string diff --git a/src/internal/docker/cli.go b/src/internal/docker/cli.go index 54d5336..aa9b540 100644 --- a/src/internal/docker/cli.go +++ b/src/internal/docker/cli.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "os/exec" + "regexp" "strings" "github.com/mitchellh/go-homedir" @@ -30,13 +31,15 @@ func Start(ctx context.Context, yeyCtx yey.Context, containerName string) error } } +var newlines = regexp.MustCompile(`\r?\n`) + func ListContainers(ctx context.Context) ([]string, error) { cmd := exec.Command("docker", "ps", "--all", "--filter", "name=yey-*", "--format", "{{.Names}}") output, err := cmd.Output() if err != nil { return nil, err } - return strings.Split(string(output), "\n"), nil + return newlines.Split(string(output), -1), nil } func getContainerStatus(ctx context.Context, name string) (string, error) { @@ -61,12 +64,12 @@ func runContainer(ctx context.Context, yeyCtx yey.Context, containerName string) args := []string{ "run", - "--name", containerName, "-it", - // "--env LS_COLORS", - // "--env TERM", - // "--env TERM_COLOR", - // "--env TERM_PROGRAM", + "--name", containerName, + "--env", "LS_COLORS", + "--env", "TERM", + "--env", "TERM_COLOR", + "--env", "TERM_PROGRAM", "--env", "YEY_WORK_DIR=" + cwd, "--env", "YEY_CONTEXT=" + yeyCtx.Name, }