You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2019/04/17 15:42:20 UTC

[GitHub] [camel-k] lburgazzoli commented on a change in pull request #623: Build improvements

lburgazzoli commented on a change in pull request #623: Build improvements
URL: https://github.com/apache/camel-k/pull/623#discussion_r276308065
 
 

 ##########
 File path: pkg/builder/builder_steps.go
 ##########
 @@ -22,38 +22,99 @@ import (
 	"io/ioutil"
 	"os"
 	"path"
+	"reflect"
 	"strings"
 
 	k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 
 	"github.com/scylladb/go-set/strset"
 
 	"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
+	"github.com/apache/camel-k/pkg/util/maven"
 	"github.com/apache/camel-k/pkg/util/tar"
 
 	yaml2 "gopkg.in/yaml.v2"
 
 	"github.com/pkg/errors"
-
-	"github.com/apache/camel-k/pkg/util/maven"
 )
 
-// GenerateProject --
-func GenerateProject(ctx *Context) error {
+var StepsByID = make(map[string]Step)
+
+func init() {
+	RegisterSteps(Steps)
+}
+
+type steps struct {
+	GenerateProject      Step
+	InjectDependencies   Step
+	SanitizeDependencies Step
+	ComputeDependencies  Step
+	StandardPackager     Step
+	IncrementalPackager  Step
+}
+
+var Steps = steps{
+	GenerateProject: NewStep(
+		"project/generate",
+		ProjectGenerationPhase,
+		generateProject,
+	),
+	InjectDependencies: NewStep(
+		"project/inject-dependencies",
+		ProjectGenerationPhase+1,
+		injectDependencies,
+	),
+	SanitizeDependencies: NewStep(
+		"project/sanitize-dependencies",
+		ProjectGenerationPhase+2,
+		sanitizeDependencies,
+	),
+	ComputeDependencies: NewStep(
+		"build/compute-dependencies",
+		ProjectBuildPhase,
+		computeDependencies,
+	),
+	StandardPackager: NewStep(
+		"packager",
+		ApplicationPackagePhase,
+		standardPackager,
+	),
+	IncrementalPackager: NewStep(
+		"packager/incremental",
+		ApplicationPackagePhase,
+		incrementalPackager,
+	),
+}
+
+func RegisterSteps(steps interface{}) {
+	v := reflect.ValueOf(steps)
+	for i := 0; i < v.NumField(); i++ {
+		if step, ok := v.Field(i).Interface().(Step); ok {
+			RegisterStep(step)
+		}
+	}
+}
+
+func RegisterStep(steps ...Step) {
+	for _, step := range steps {
+		StepsByID[step.ID()] = step
 
 Review comment:
   now that the id has a real meaning wondering if we need to add some tests/check to avoid overriding a step by mistake

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services