Skip to content

Commit

Permalink
Add platform label to interfaces
Browse files Browse the repository at this point in the history
This used to be a separate field. Adding it back as a label.

PiperOrigin-RevId: 297680529
Change-Id: I2fed1222f45182467c0f8e07f9b58e6b7f7c8601
  • Loading branch information
cdvoisin authored and copybara-github committed Feb 27, 2020
1 parent feaa0c0 commit 7c0e9ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/dam/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestConfigHandlers(t *testing.T) {

role := `{"roleCategories":["metadata"],"policyBasis":{"AcceptedTermsAndPolicies":true,"ResearcherStatus":true}}`
roles := `{"discovery":` + role + `}`
beacon := `{"serviceTemplate":"beacon",*,"contentTypes":["application/bam"],"roles":` + roles + `,"ui":{"description":"Search data from Beacon Discovery","label":"Beacon Discovery"},"interfaces":{"http:beacon":{"uri":["https://gatekeeper-cafe-variome.staging.dnastack.com/beacon/query"],"labels":{*}}}}`
beacon := `{"serviceTemplate":"beacon",*,"contentTypes":["application/bam"],"roles":` + roles + `,"ui":{"description":"Search data from Beacon Discovery","label":"Beacon Discovery"},"interfaces":{"http:beacon":{"uri":["https://gatekeeper-cafe-variome.staging.dnastack.com/beacon/query"],"labels":{*"platform":"oauth"*}}}}`
views := `{"beacon":` + beacon + `,"gcs_read":{"serviceTemplate":"gcs",*,"contentTypes":["application/bam"],"roles":{"viewer":{"roleCategories":["list","metadata","read"],"policyBasis":{"AcceptedTermsAndPolicies":true,"ResearcherStatus":true}}},"ui":{"description":"GCS File Read","label":"File Read"},"interfaces":{"gcp:gs":{"uri":["gs://ga4gh-apis-controlled-access"],"labels":{*}},"http:gcp:gs":{"uri":["https://www.googleapis.com/storage/v1/b/ga4gh-apis-controlled-access"],"labels":{*}}}}}`
resource := `{"views":` + views + `,"maxTokenTtl":"1h","ui":{"applyUrl":"http://apply.ga4gh-apis.org","description":"Google demo of GA4GH APIs","imageUrl":"https://info.ga4gh-apis.org/images/image.jpg","infoUrl":"http://info.ga4gh-apis.org","label":"GA4GH APIs","troubleshootUrl":"http://troubleshoot.ga4gh-apis.org"}}`

Expand Down
6 changes: 5 additions & 1 deletion lib/dam/dam.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ func makeViewInterfaces(srcView *pb.View, srcRes *pb.Resource, cfg *pb.DamConfig
if !hasItemVariable(uriFmt) {
// Accept this string that has no more variables to replace.
uriMap[uriFmt] = srcView.Labels
if len(item.Labels) > 0 {
if srcView.Labels == nil || srcView.Labels["platform"] == "" || len(item.Labels) > 0 {
// Merge label lists for this item, with item.Labels overriding any view.Labels.
labels := make(map[string]string)
for k, v := range srcView.Labels {
Expand All @@ -812,6 +812,10 @@ func makeViewInterfaces(srcView *pb.View, srcRes *pb.Resource, cfg *pb.DamConfig
for k, v := range item.Labels {
labels[k] = v
}
if desc := tas.Descriptors[st.ServiceName]; desc != nil {
labels["platform"] = desc.Platform
}
uriMap[uriFmt] = labels
}
}
}
Expand Down

0 comments on commit 7c0e9ae

Please sign in to comment.