-
-
Notifications
You must be signed in to change notification settings - Fork 875
get_step: add metadata to build vars #9419
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
base: master
Are you sure you want to change the base?
Conversation
|
|
| return nil | ||
| } | ||
|
|
||
| func AsMap(metadata []atc.MetadataField) map[string]any { |
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.
There is probably a better place for this function
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.
I'd add it onto a new type of []MetadataField here:
concourse/atc/resource_types.go
Lines 10 to 13 in e81401c
| type MetadataField struct { | |
| Name string `json:"name"` | |
| Value string `json:"value"` | |
| } |
Something like:
type Metadata []MetadataField
func (m Metadata) AsMap() map[string]any {
result := make(map[string]any, len(m))
for _, v := range m {
result[v.Name] = v.Value
}
return result
}Then VersionResult can also use that type:
concourse/atc/resource/resource.go
Lines 19 to 22 in e81401c
| type VersionResult struct { | |
| Version atc.Version `json:"version"` | |
| Metadata []atc.MetadataField `json:"metadata,omitempty"` | |
| } |
Then AsMap(versionResult.Metadata) would become versionResult.Metadata.AsMap()!
|
@PentaHelix Thanks for the PR! I have added you the |
|
Thanks for the PR! Will review after I get 8.0 out. |
taylorsilva
left a comment
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.
LGTM! I suggested how you can refactor AsMap() if you want to. As-is though, this works as expected.
Given this pipeline:
resources:
- name: metadata
type: mock
source:
metadata:
- name: hello
value: from metadata
- name: hope
value: it works!
jobs:
- name: job
plan:
- get: metadata
- task: echo
config:
platform: linux
image_resource:
type: mock
source:
mirror_self: true
run:
path: bash
args:
- -c
- |
echo ((.:metadata.hello))
echo ((.:metadata.hope))It worked!
If you don't have time to refactor I'll merge it as-is and refactor it later. Let me know. Thanks again for the PR!
| return nil | ||
| } | ||
|
|
||
| func AsMap(metadata []atc.MetadataField) map[string]any { |
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.
I'd add it onto a new type of []MetadataField here:
concourse/atc/resource_types.go
Lines 10 to 13 in e81401c
| type MetadataField struct { | |
| Name string `json:"name"` | |
| Value string `json:"value"` | |
| } |
Something like:
type Metadata []MetadataField
func (m Metadata) AsMap() map[string]any {
result := make(map[string]any, len(m))
for _, v := range m {
result[v.Name] = v.Value
}
return result
}Then VersionResult can also use that type:
concourse/atc/resource/resource.go
Lines 19 to 22 in e81401c
| type VersionResult struct { | |
| Version atc.Version `json:"version"` | |
| Metadata []atc.MetadataField `json:"metadata,omitempty"` | |
| } |
Then AsMap(versionResult.Metadata) would become versionResult.Metadata.AsMap()!
Changes proposed by this PR
get steps provide their metadata to the job as build variables