2018-10-02 03:50:05 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2018-10-17 05:37:19 +02:00
|
|
|
"github.com/spf13/cobra"
|
2019-10-03 22:46:29 +02:00
|
|
|
"github.com/spf13/viper"
|
2023-07-07 04:01:46 +02:00
|
|
|
|
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"
|
2018-10-02 03:50:05 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// buildCmd represents the build command
|
|
|
|
var buildCmd = &cobra.Command{
|
2018-10-20 13:42:01 +02:00
|
|
|
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,
|
2018-10-02 03:50:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2019-03-16 16:10:47 +01:00
|
|
|
initLogging()
|
|
|
|
|
2019-10-03 22:46:29 +02:00
|
|
|
// 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{
|
2019-07-26 16:27:00 +02:00
|
|
|
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,
|
2019-07-26 16:27:00 +02:00
|
|
|
CiConfig: ciConfig,
|
2018-12-30 20:07:56 +01:00
|
|
|
})
|
2018-10-14 16:55:54 +02:00
|
|
|
}
|