- 
                Notifications
    
You must be signed in to change notification settings  - Fork 6
 
Add support for request context #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
          Codecov ReportAttention: Patch coverage is  @@                 Coverage Diff                  @@
##           infrahub-develop     #296      +/-   ##
====================================================
- Coverage             70.62%   70.56%   -0.07%     
====================================================
  Files                    85       86       +1     
  Lines                  7824     7867      +43     
  Branches               1513     1523      +10     
====================================================
+ Hits                   5526     5551      +25     
- Misses                 1908     1920      +12     
- Partials                390      396       +6     
 Flags with carried forward coverage won't be shown. Click here to find out more. 
 ... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
  | 
    
2a4e4ec    to
    df19431      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this implementation, will it be possible to define the context globally when we initialize the client ? I think this is important to support this option in addition to specifying a specific context for a specific request
          
 If you check the first example in the description that's very close to this. The scenario I was picturing was specifically for use with the generators, where we'd want to set the context on a cloned client after it was cloned. The use case I'd see to have it directly on the initialize would be when we support running jobs within an isolated Docker container or pod, but perhaps you have some other use case that I'm missing?  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you check the first example in the description that's very close to this. The scenario I was picturing was specifically for use with the generators, where we'd want to set the context on a cloned client after it was cloned. The use case I'd see to have it directly on the initialize would be when we support running jobs within an isolated Docker container or pod, but perhaps you have some other use case that I'm missing?
My bad I missed it, this is exactly what I had in mind too
df19431    to
    03772f1      
    Compare
  
    | 
           I've also updated the protocols that were falling behind, will revisit with an integration test once we have an image to test against. This will also be used in #5985.  | 
    
Adds support for adding a request context to the SDK. This can be done at the root level of the client object or on individual requests. The idea here is that when running a generator we'd want to simplify this process for end users so that we add the context to the cloned SDK instance when running within the pipeline where as we wouldn't use this option when using
infrahubctl.Within the Infrahub pipeline we'd still need to be able to specify that specific objects should be saved using a context, such as when creating a validator or a check, then we are not able to set the context for the entire SDK instance.
There are still some calls missing (such as when creating branches etc) and tests would need to be written.
It would be used either like this:
Alternatively like this: