// RunNewBuild contains all the necessary functionality for the OpenShift cli new-build command func RunNewBuild(fullName string, f *clientcmd.Factory, out io.Writer, c *cobra.Command, args []string, config *newcmd.AppConfig) error { if err := setupAppConfig(f, c, args, config); err != nil { return err } result, err := config.RunBuilds(out) if err != nil { if errs, ok := err.(errors.Aggregate); ok { if len(errs.Errors()) == 1 { err = errs.Errors()[0] } } if err == newcmd.ErrNoInputs { // TODO: suggest things to the user return cmdutil.UsageError(c, "You must specify one or more images, image streams and source code locations to create a build configuration.") } return err } if err := setLabels(c, result); err != nil { return err } if len(cmdutil.GetFlagString(c, "output")) != 0 { return f.Factory.PrintObject(c, result.List, out) } if err := createObjects(f, out, result); err != nil { return err } for _, item := range result.List.Items { switch t := item.(type) { case *buildapi.BuildConfig: fmt.Fprintf(c.Out(), "A build configuration was created - you can run `%s start-build %s` to start it.\n", fullName, t.Name) } } return nil }