Skip to content
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

enhance(templates): inject template name as variable #1096

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

ecrupper
Copy link
Contributor

Example pipeline:

.vela.yml

version: "1"

metadata:
  render_inline: true

templates:
  - name: example
    source: example.yml
    type: file

example.yml

metadata:
  template: true

stages:
  wait:
    steps:
      - name: run
        image: alpine
        commands:
          - sleep 20
          - printenv

  test:
    needs: [ wait ]
    steps:
      - name: run
        image: alpine
        commands:
          - echo "Hello World"

Due to the fact that the steps and stages get modified to include the template name, this configuration will not work due to wait stage being transformed to example_wait. With this change, that part can be modified to

needs: [{{ .VELA_TEMPLATE_NAME }}_wait]

This is beneficial to developing widely used templates without instructing all adopters to use the same template name.

@ecrupper ecrupper requested a review from a team as a code owner March 27, 2024 15:59
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.26%. Comparing base (5706d0f) to head (53b7b36).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1096      +/-   ##
==========================================
+ Coverage   63.24%   63.26%   +0.02%     
==========================================
  Files         348      348              
  Lines       10594    10600       +6     
==========================================
+ Hits         6700     6706       +6     
  Misses       3409     3409              
  Partials      485      485              
Files Coverage Δ
compiler/native/compile.go 69.58% <100.00%> (+0.35%) ⬆️
compiler/native/expand.go 68.68% <100.00%> (+0.52%) ⬆️

Copy link
Contributor

@KellyMerrick KellyMerrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ecrupper ecrupper merged commit 5af11c2 into main Mar 29, 2024
11 of 13 checks passed
@ecrupper ecrupper deleted the enhance/compiler/native-template-name-var branch March 29, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants