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

deliminates data stream and route with an underscore #533

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
96 changes: 96 additions & 0 deletions upload-server/configs/testing/file_destinations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
version: 1.0

az-edav: &az-edav
endpoint: "http://azurite:10000/devstoreaccount1"
storage_account: "devstoreaccount1"
storage_key: $AZURITE_KEY
container_name: edav

az-ehdi: &az-ehdi
endpoint: "http://azurite:10000/devstoreaccount1"
storage_account: "devstoreaccount1"
storage_key: $AZURITE_KEY
container_name: ehdi

az-eicr: &az-eicr
endpoint: "http://azurite:10000/devstoreaccount1"
storage_account: "devstoreaccount1"
storage_key: $AZURITE_KEY
container_name: eicr

az-ncird: &az-ncird
endpoint: "http://azurite:10000/devstoreaccount1"
storage_account: "devstoreaccount1"
storage_key: $AZURITE_KEY
container_name: ncird

# if needed, properties of an anchor can be overridden
# in a delivery target
#
# path_template can be defined at data_stream level
# where it is valid for all targets unless
# a target defines its own path_template property
programs:
- data_stream_id: pulsenet
data_stream_route: localsequencefile
delivery_targets:
- name: edav
type: file
path: ./uploads/edav
- data_stream_id: ehdi
data_stream_route: csv
delivery_targets:
- name: ehdi
type: file
path: ./uploads/ehdi
- data_stream_id: eicr
data_stream_route: fhir
delivery_targets:
- name: eicr
type: file
path: ./uploads/eicr
- data_stream_id: rsp-prevention
data_stream_route: csv
delivery_targets:
- name: ncird
type: file
path: ./uploads/ncird
- data_stream_id: generic-immunization
data_stream_route: csv
delivery_targets:
- name: ncird
type: file
path: ./uploads/ncird
- data_stream_id: influenza-vaccination
data_stream_route: csv
delivery_targets:
- name: ncird
type: file
path: ./uploads/ncird
- data_stream_id: routine-immunization
data_stream_route: other
delivery_targets:
- name: ncird
type: file
path: ./uploads/ncird
- data_stream_id: rsp-prevention
data_stream_route: csv
delivery_targets:
- name: ncird
type: file
path: ./uploads/ncird
- data_stream_id: dextesting
data_stream_route: testevent1
delivery_targets:
- name: ncird
type: file
path: ./uploads/ncird
- name: eicr
type: file
path: ./uploads/eicr
- name: edav
type: file
path: ./uploads/edav
- name: ehdi
type: file
path: ./uploads/ehdi
8 changes: 4 additions & 4 deletions upload-server/internal/metadata/v2/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
"fmt"
)

type Config struct {
type ConfigIdentification struct {
DataStreamID string
DataStreamRoute string
}

func (c *Config) Path() string {
path := fmt.Sprintf("%s/%s-%s.json", "v2", c.DataStreamID, c.DataStreamRoute)
func (c *ConfigIdentification) Path() string {
path := fmt.Sprintf("%s/%s_%s.json", "v2", c.DataStreamID, c.DataStreamRoute)
return path
}

Expand All @@ -29,7 +29,7 @@ func NewFromManifest(manifest handler.MetaData) (validation.ConfigLocation, erro
return nil, errors.Join(validation.ErrFailure, &validation.ErrorMissing{Field: "data_stream_route"})
}

return &Config{
return &ConfigIdentification{
DataStreamID: dataStreamID,
DataStreamRoute: dataStreamRoute,
}, nil
Expand Down
8 changes: 7 additions & 1 deletion upload-server/internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"embed"
"encoding/json"
"fmt"
v2 "github.com/cdcgov/data-exchange-upload/upload-server/internal/metadata/v2"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -126,7 +127,12 @@ func GetRouter(uploadUrl string, infoUrl string) *mux.Router {
dataStream := r.FormValue("data_stream_id")
dataStreamRoute := r.FormValue("data_stream_route")

config, err := metadata.Cache.GetConfig(r.Context(), fmt.Sprintf("v2/%s-%s.json", dataStream, dataStreamRoute))
configId := v2.ConfigIdentification{
DataStreamID: dataStream,
DataStreamRoute: dataStreamRoute,
}

config, err := metadata.Cache.GetConfig(r.Context(), configId.Path())
if err != nil {
http.Error(rw, err.Error(), http.StatusNotFound)
return
Expand Down
24 changes: 12 additions & 12 deletions upload-server/testing/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ func TestGetFileDeliveryPrefixDate(t *testing.T) {
ctx := context.TODO()
m := map[string]string{
"version": "2.0",
"data_stream_id": "test_stream",
"data_stream_route": "test_route",
"data_stream_id": "test-stream",
"data_stream_route": "test-route",
}
metadata.Cache.SetConfig("v2/test_stream-test_route.json", &validation.ManifestConfig{
metadata.Cache.SetConfig("v2/test-stream_test-route.json", &validation.ManifestConfig{
Copy: validation.CopyConfig{
FolderStructure: metadata.FolderStructureDate,
},
Expand All @@ -313,10 +313,10 @@ func TestGetFileDeliveryPrefixRoot(t *testing.T) {
ctx := context.TODO()
m := map[string]string{
"version": "2.0",
"data_stream_id": "test_stream",
"data_stream_route": "test_route",
"data_stream_id": "test-stream",
"data_stream_route": "test-route",
}
metadata.Cache.SetConfig("v2/test_stream-test_route.json", &validation.ManifestConfig{
metadata.Cache.SetConfig("v2/test-stream_test-route.json", &validation.ManifestConfig{
Copy: validation.CopyConfig{
FolderStructure: metadata.FolderStructureRoot,
},
Expand All @@ -337,11 +337,11 @@ func TestDeliveryFilenameSuffixUploadId(t *testing.T) {
ctx := context.TODO()
m := map[string]string{
"version": "2.0",
"data_stream_id": "test_stream",
"data_stream_route": "test_route",
"data_stream_id": "test-stream",
"data_stream_route": "test-route",
}
tuid := "1234"
metadata.Cache.SetConfig("v2/test_stream-test_route.json", &validation.ManifestConfig{
metadata.Cache.SetConfig("v2/test-stream_test-route.json", &validation.ManifestConfig{
Copy: validation.CopyConfig{
FilenameSuffix: metadata.FilenameSuffixUploadId,
},
Expand All @@ -360,11 +360,11 @@ func TestDeliveryFilenameSuffixNone(t *testing.T) {
ctx := context.TODO()
m := map[string]string{
"version": "2.0",
"data_stream_id": "test_stream",
"data_stream_route": "test_route",
"data_stream_id": "test-stream",
"data_stream_route": "test-route",
}
tuid := "1234"
metadata.Cache.SetConfig("v2/test_stream-test_route.json", &validation.ManifestConfig{
metadata.Cache.SetConfig("v2/test-stream_test-route.json", &validation.ManifestConfig{
Copy: validation.CopyConfig{
FilenameSuffix: "",
},
Expand Down
Loading