Repository navigation
feat(atc): support named var. - #4777
Conversation
|
My test pipeline: var_sources:
- name: dev-vault
type: vault
config:
url: http://192.168.1.12:8200
path_prefix: concourse
skip_team_path: true
client_token: ((my-vault-token))
- name: vs-dummy
type: dummy
config:
vars:
clone-pass: ((dev-vault:test.pass))
resource_types:
- name: rt-tiny
type: registry-image
source:
repository: evanli/tiny2
tag: v2
resources:
- name: tiny
type: rt-tiny
check_every: 2m
source:
key: ((dev-vault:hello))
jobs:
- name: test
public: true
plan:
- get: tiny
params:
other_key: ((dev-vault:test.pass))
- task: task-should-succeed
config:
platform: linux
image_resource:
type: registry-image
source: {repository: busybox}
run:
path: sh
args:
- -exc
- |
echo The pass is ((dev-vault:test.pass)) and clone-pass is ((vs-dummy:clone-pass))
- task: task-should-fail
config:
platform: linux
image_resource:
type: registry-image
source: {repository: busybox}
run:
path: sh
args:
- -exc
- |
echo The name is ((test.pass))Where the first task use var_source name with the vars, which should pass; and the second task uses var names without var_source name, then it will look for vars from the system vault, and will not find, then fail. The UI screen shot proves the test passed: |
112b168 to
9b946f5
Compare
|
@tylorsilva sorry for the confusion. I think 4580 was added by auto completion. I didn’t notice that, just removed that. |
|
@vito Can you please review this? It’s ready for review. |
d1fda8c to
20e1990
Compare
|
I added a new config |
89e8b22 to
939dda2
Compare
|
@vito I communicated with some of our users this week, and they felt that allowing a var_source to refer to previous var_sources would be helpful, which is same as what you have proposed in RFC: var_sources. So I just added a new commit to support that, as you can see, the code is actually very simple. The only restriction is, if var_source B refer to var_source A, then A must be defined before B. Though we can add some code to eliminate the restriction by ordering var_sources by dependencies, but I think it's fair to require a var_source to be defined before using it. edit: During my test, I finally realized that we have to order var_sources at runtime. Because if we just swap order of var_sources in YAML, |
f967b63 to
f6f0529
Compare
|
Just rebased and resolved conflicts. |
vito
left a comment
There was a problem hiding this comment.
Sorry for the wait! This looks great so far. Left some suggestions inline. And I think the skipTeamPath stuff should probably be split out.
We'll try to get this in for v5.8 but we're already overdue so we might end up shipping without it. No rush, we can always just ship again. v5.8 can be set_pipeline, v5.9 can be var_sources. 🙂
If the feedback makes sense let me know if you think you can make the changes in time! We can push out the release for a bit more.
Signed-off-by: Chao Li <[email protected]>
…ret lookup will skip paths of team/ and team/pipeline/. Signed-off-by: Chao Li <[email protected]>
Signed-off-by: Chao Li <[email protected]>
Signed-off-by: Chao Li <[email protected]>
Signed-off-by: Chao Li <[email protected]>
f6f0529 to
6cc09c2
Compare
…hat, secret lookup will skip paths of team/ and team/pipeline/." This reverts commit a15ee7e. Signed-off-by: Chao Li <[email protected]>
36b80b8 to
ae303d0
Compare
|
@vito I have just addressed all review comments:
I hope var source to be included in 5.8, because our users are waiting for that, I don't want them to wait the other month for 5.9. Also, I plan to work on input_vars, based on code of this PR, input_var should be easy to implement. My roadmap is to contribute "input_vars" and "OPA integration" to 5.9, I have submitted RFCs for both of them. "OPA integration" is an urgent feature for us, actually I have finished coding but haven't submitted a PR yet. "input_vars" is not urgent, but very nice to have, that will somewhat change the way of creating pipelines, reducing development effort of tasks and resource types. |
vito
left a comment
There was a problem hiding this comment.
My only feedback is a tiny refactor so I think this is good to go. 👍 Will leave this open until we're closer to v5.8 in case you want to sneak it in.
Thanks a bunch!
|
Looks like web_1 | {"timestamp":"2019-12-11T17:51:26.763230340Z","level":"debug","source":"atc","message":"atc.pipelines.radar.scan-resource.interval-runner.tick.found-existing-credential-manager","data":{"pipeline":"tf-pipeline-4-5a94a3bd-e9d4-4343-6453-6ee8ddabdf3c","resource":"resource-using-vars","session":"16.55.27.1.1","team":"testflight"}}
web_1 | {"timestamp":"2019-12-11T17:51:26.763466054Z","level":"error","source":"atc","message":"atc.pipelines.radar.scan-resource.interval-runner.tick.failed-to-evaluate-resource-source","data":{"error":"undefined vars: vs:initial_version_var, vs:some_numeric_var","pipeline":"tf-pipeline-4-5a94a3bd-e9d4-4343-6453-6ee8ddabdf3c","resource":"resource-using-vars","session":"16.55.27.1.1","team":"testflight"}}
web_1 | {"timestamp":"2019-12-11T17:51:26.765630634Z","level":"error","source":"atc","message":"atc.pipelines.radar.failed-to-run-scan-resource","data":{"error":"undefined vars: vs:initial_version_var, vs:some_numeric_var","pipeline":"tf-pipeline-4-5a94a3bd-e9d4-4343-6453-6ee8ddabdf3c","session":"16.55","team":"testflight"}} |
Signed-off-by: Chao Li <[email protected]>
@vito Thank the I have fixed the bug, and enhanced the unit tests to cover both single var_source and multiple var_sources cases. BTW, why are we no longer able to see build logs? Looks like the pipelines are not exposed to public now. |
vito
left a comment
There was a problem hiding this comment.
Sneaky midnight review! Noticed one more tiny thing I think we should fix.
We're in the midst of re-paving our CI stack, so for now the URL of our CI is https://nci.concourse-ci.org. I'm able to view the PR builds anonymously at least but it looks like we need to expose a few other pipelines that have been moved over, if it's those you were looking for. We'll switch the DNS back to ci.concourse-ci.org once we're completely switched over.
Signed-off-by: Chao Li <[email protected]>
Thanks for working so late. I just realized that I can see build logs now. |
vito
left a comment
There was a problem hiding this comment.
Good to go - thanks a bunch!
I'm working on docs for var_sources today - we'll get it in v5.8.

Existing Issue
This is a a follow-up enhancement of PR #4600, and complies with RFC Conourse/RFC#39.
Why do we need this PR?
This PR makes pipeline var_source fully functional.
Changes proposed in this pull request
Basically this change is neat.
namedSecrets. It extract var_source name fromsecretPath, then checks var_source and forward realGetto the underlying secrets.VarSourcePoolwill always returnsnamedSecretswith original secrets wrapped in it.template.goto accept named var like((vs:var)).Contributor Checklist
Reviewer Checklist
and Helm packaging; otherwise, ignored for the integration tests (for example, if they are Garden configs that are not displayed in the
--helptext).