spud/cli/build.go

31 lines
602 B
Go

package cli
import (
"github.com/spf13/cobra"
"log"
podman "spud/podman"
service_definition "spud/service_definition"
)
var build = &cobra.Command{
Use: "build",
Short: "Build service images.",
Run: func(cmd *cobra.Command, args []string) {
pathProvided := args[0]
def, err := service_definition.GetServiceDefinitionFromFile(pathProvided)
if err != nil {
log.Fatal(err)
}
imagesToBuild := def.Build.Images
if len(imagesToBuild) == 0 {
log.Print("No images defined - nothing to build!")
}
for _, imageDef := range imagesToBuild {
podman.Build(imageDef)
}
},
}