-
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.
# Conflicts: # src/cmd/run/run.go
- Loading branch information
Showing
14 changed files
with
315 additions
and
22 deletions.
There are no files selected for viewing
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,3 @@ | ||
build: | ||
dockerfile: ./Dockerfile | ||
context: . |
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,3 @@ | ||
FROM ubuntu:latest | ||
|
||
CMD ["bash"] |
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,6 +1,6 @@ | ||
module github.com/silphid/yey | ||
|
||
go 1.14 | ||
go 1.16 | ||
|
||
require ( | ||
github.com/AlecAivazis/survey/v2 v2.2.12 | ||
|
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,53 @@ | ||
package remove | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/silphid/yey/src/cmd" | ||
yey "github.com/silphid/yey/src/internal" | ||
"github.com/silphid/yey/src/internal/docker" | ||
) | ||
|
||
// New creates a cobra command | ||
func New() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "remove", | ||
Aliases: []string{"rm"}, | ||
Short: "Removes context container", | ||
Args: cobra.RangeArgs(0, 1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
name := "" | ||
if len(args) == 1 { | ||
name = args[0] | ||
} | ||
return run(cmd.Context(), name) | ||
}, | ||
} | ||
} | ||
|
||
func run(ctx context.Context, name string) error { | ||
contexts, err := yey.LoadContexts() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if name == "" { | ||
var err error | ||
name, err = cmd.PromptContext(contexts) | ||
if err != nil { | ||
return fmt.Errorf("failed to prompt for desired context: %w", err) | ||
} | ||
} | ||
|
||
context, err := contexts.GetContext(name) | ||
if err != nil { | ||
return fmt.Errorf("failed to get context with name %q: %w", name, err) | ||
} | ||
|
||
container := yey.ContainerName(contexts.Path, context) | ||
|
||
return docker.Remove(ctx, container) | ||
} |
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
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
Oops, something went wrong.