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:46:36 UTC
[GitHub] [camel-k] astefanutti commented on a change in pull request #623:
Build improvements
astefanutti commented on a change in pull request #623: Build improvements
URL: https://github.com/apache/camel-k/pull/623#discussion_r276310292
##########
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:
Yes I thought about it but got somehow a bit lazy 🙈. I guess we can fail-fast and panic because step overriding should not happen.
----------------------------------------------------------------
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