Marc Cataford
5a18a5bf44
All checks were successful
Pull-Request / tests (pull_request) Successful in 1m6s
Pull-Request / static-analysis (pull_request) Successful in 1m31s
Pull-Request / post-run (pull_request) Successful in 24s
Push / pre-run (push) Successful in 28s
Push / tests (push) Successful in 1m3s
Push / static-analysis (push) Successful in 1m29s
Push / post-run (push) Successful in 38s
docs: add documentation to core functions and structs
43 lines
984 B
Go
43 lines
984 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/spf13/cobra"
|
|
"log"
|
|
podman "spud/podman"
|
|
service_definition "spud/service_definition"
|
|
)
|
|
|
|
func getBuildCommand() *cobra.Command {
|
|
build := &cobra.Command{
|
|
Use: "build",
|
|
Short: "Build service images.",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
pathProvided, err := cmd.PersistentFlags().GetString("definition")
|
|
|
|
if err != nil {
|
|
return fmt.Errorf("%+v", err)
|
|
}
|
|
def, err := service_definition.NewDefinitionFetcher().GetDefinition(pathProvided)
|
|
|
|
if err != nil {
|
|
return fmt.Errorf("Failed to read service definition from file: %+v", err)
|
|
}
|
|
|
|
imagesToBuild := def.Build.Images
|
|
|
|
if len(imagesToBuild) == 0 {
|
|
log.Print("No images defined - nothing to build!")
|
|
}
|
|
|
|
for _, imageDef := range imagesToBuild {
|
|
podman.Build(imageDef)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
build.PersistentFlags().StringP("definition", "d", "./service.yml", "Path to the service definition to use.")
|
|
|
|
return build
|
|
|
|
}
|