[GitHub] lburgazzoli opened a new issue #268: Refactor traits lifecycle

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] lburgazzoli opened a new issue #268: Refactor traits lifecycle

GitBox
lburgazzoli opened a new issue #268: Refactor traits lifecycle
URL: https://github.com/apache/camel-k/issues/268
 
 
   The current trait life-cycle is something like:
   
   * check if it can be applied to the current environment
   * check if it should auto-configure
      * auto-configure it
   * check if it is enabled
      * execute it
   
   I think that we can condense the first three steps in a single one who is responsible to set up the trait according to the given environment and user parameters, validate the set-up and finally determine if the trait should be executed or not.
   
   The `Trait` interface then would look like:
   
   ```go
   type Trait interface {
       Identifiable
   
       Configure() (bool, err)
       Apply(environment *Environment) error
   }
   ```
   
   The _trait loop_ then would look like:
   
   ```go
   for _, trait := range traits {
       enabled, err := trait.Configure(env)
       if err != nil {
           return err
       }
   
       if enabled {
           if err := trait.Apply(env); err != nil {
       return err
    }
   
           env.ExecutedTraits = append(env.ExecutedTraits, trait.ID())
       }
   }
   ```
   
   @nicolaferraro make sense ?
   

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


With regards,
Apache Git Services