New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split cli into moby and linuxkit #1695
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
File renamed without changes.
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,95 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
log "github.com/Sirupsen/logrus" | ||
) | ||
|
||
var ( | ||
defaultLogFormatter = &log.TextFormatter{} | ||
|
||
// Version is the human-readable version | ||
Version = "unknown" | ||
|
||
// GitCommit hash, set at compile time | ||
GitCommit = "unknown" | ||
) | ||
|
||
// infoFormatter overrides the default format for Info() log events to | ||
// provide an easier to read output | ||
type infoFormatter struct { | ||
} | ||
|
||
func (f *infoFormatter) Format(entry *log.Entry) ([]byte, error) { | ||
if entry.Level == log.InfoLevel { | ||
return append([]byte(entry.Message), '\n'), nil | ||
} | ||
return defaultLogFormatter.Format(entry) | ||
} | ||
|
||
func version() { | ||
fmt.Printf("%s version %s\n", filepath.Base(os.Args[0]), Version) | ||
fmt.Printf("commit: %s\n", GitCommit) | ||
os.Exit(0) | ||
} | ||
|
||
func main() { | ||
flag.Usage = func() { | ||
fmt.Printf("USAGE: %s [options] COMMAND\n\n", filepath.Base(os.Args[0])) | ||
fmt.Printf("Commands:\n") | ||
fmt.Printf(" push Push a VM image to a cloud or image store\n") | ||
fmt.Printf(" run Run a VM image on a local hypervisor or remote cloud\n") | ||
fmt.Printf(" version Print version information\n") | ||
fmt.Printf(" help Print this message\n") | ||
fmt.Printf("\n") | ||
fmt.Printf("Run '%s COMMAND --help' for more information on the command\n", filepath.Base(os.Args[0])) | ||
fmt.Printf("\n") | ||
fmt.Printf("Options:\n") | ||
flag.PrintDefaults() | ||
} | ||
flagQuiet := flag.Bool("q", false, "Quiet execution") | ||
flagVerbose := flag.Bool("v", false, "Verbose execution") | ||
|
||
// Set up logging | ||
log.SetFormatter(new(infoFormatter)) | ||
log.SetLevel(log.InfoLevel) | ||
flag.Parse() | ||
if *flagQuiet && *flagVerbose { | ||
fmt.Printf("Can't set quiet and verbose flag at the same time\n") | ||
os.Exit(1) | ||
} | ||
if *flagQuiet { | ||
log.SetLevel(log.ErrorLevel) | ||
} | ||
if *flagVerbose { | ||
// Switch back to the standard formatter | ||
log.SetFormatter(defaultLogFormatter) | ||
log.SetLevel(log.DebugLevel) | ||
} | ||
|
||
args := flag.Args() | ||
if len(args) < 1 { | ||
fmt.Printf("Please specify a command.\n\n") | ||
flag.Usage() | ||
os.Exit(1) | ||
} | ||
|
||
switch args[0] { | ||
case "push": | ||
push(args[1:]) | ||
case "run": | ||
run(args[1:]) | ||
case "version": | ||
version() | ||
case "help": | ||
flag.Usage() | ||
default: | ||
fmt.Printf("%q is not valid command.\n\n", args[0]) | ||
flag.Usage() | ||
os.Exit(1) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a brief explanation of the difference between the linuxkit and moby tools? I realize we'll continue to shuffle things around but might be helpful in the intermediate stage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still am trying to wrap my head around it. Is the short form:
moby
is a tool for building images, andlinuxkit
is a tool for pushing and running images? Somoby == docker build
andlinuxkit == docker run / docker push
?And if so... why? What do we gain by having 2 distinct tools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. And the
moby
tool will be moved and extended to build assemblies other than linux images. This was discussed at length at DockerCon and various meetings after. I'm not sure there is a good writeup yet