dive/cmd/build.go

39 lines
1 KiB
Go
Raw Normal View History

package cmd
import (
2018-10-17 05:37:19 +02:00
"github.com/spf13/cobra"
"github.com/spf13/viper"
2019-10-02 21:48:10 +02:00
"github.com/wagoodman/dive/dive"
2018-12-30 20:07:56 +01:00
"github.com/wagoodman/dive/runtime"
)
// buildCmd represents the build command
var buildCmd = &cobra.Command{
Use: "build [any valid `docker build` arguments]",
Short: "Builds and analyzes a docker image from a Dockerfile (this is a thin wrapper for the `docker build` command).",
2018-10-14 16:55:54 +02:00
DisableFlagParsing: true,
2018-12-08 17:46:09 +01:00
Run: doBuildCmd,
}
func init() {
rootCmd.AddCommand(buildCmd)
2018-10-14 16:55:54 +02:00
}
2018-12-08 17:46:09 +01:00
// doBuildCmd implements the steps taken for the build command
func doBuildCmd(cmd *cobra.Command, args []string) {
initLogging()
// there is no cli options allowed, only config can be supplied
// todo: allow for an engine flag to be passed to dive but not the container engine
engine := viper.GetString("container-engine")
2019-10-02 21:48:10 +02:00
2018-12-30 20:07:56 +01:00
runtime.Run(runtime.Options{
Ci: isCi,
2019-10-09 00:55:03 +02:00
Source: dive.ParseImageSource(engine),
2018-12-30 20:07:56 +01:00
BuildArgs: args,
ExportFile: exportFile,
CiConfig: ciConfig,
2018-12-30 20:07:56 +01:00
})
2018-10-14 16:55:54 +02:00
}