40 lines
901 B
Go
40 lines
901 B
Go
// Start services
|
|
//
|
|
// Commands related to starting services.
|
|
|
|
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/spf13/cobra"
|
|
service "spud/service"
|
|
service_definition "spud/service_definition"
|
|
)
|
|
|
|
func getStartCommand() *cobra.Command {
|
|
start := &cobra.Command{
|
|
Use: "start",
|
|
Short: "Creates or updates a service based on the provided definition.",
|
|
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.GetServiceDefinitionFromFile(pathProvided)
|
|
|
|
if err != nil {
|
|
return fmt.Errorf("Failed to read service definition from file: %+v", err)
|
|
}
|
|
|
|
service.CreateService(def)
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
start.PersistentFlags().StringP("definition", "d", "./service.yml", "Path to the service definition to use.")
|
|
|
|
return start
|
|
}
|