diff --git a/lib/dam/config_test.go b/lib/dam/config_test.go index ceba5ee7..45208d00 100644 --- a/lib/dam/config_test.go +++ b/lib/dam/config_test.go @@ -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"}}` diff --git a/lib/dam/dam.go b/lib/dam/dam.go index 5d5f49f6..1a2449d4 100644 --- a/lib/dam/dam.go +++ b/lib/dam/dam.go @@ -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 { @@ -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 } } }