Skip to content

Commit

Permalink
Aligning SDS API Base URL naming with runner (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylelawsonAND authored Jul 21, 2023
1 parent 474c432 commit 814d206
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init() {
setSetting("SURVEY_RUNNER_SCHEMA_URL", Get("SURVEY_RUNNER_URL"))
setSetting("SCHEMA_VALIDATOR_URL", "")
setSetting("SURVEY_REGISTER_URL", "")
setSetting("SDS_API_URL", "http://localhost:5003")
setSetting("SDS_API_BASE_URL", "http://localhost:5003")
setSetting("JWT_ENCRYPTION_KEY_PATH", "jwt-test-keys/sdc-user-authentication-encryption-sr-public-key.pem")
setSetting("JWT_SIGNING_KEY_PATH", "jwt-test-keys/sdc-user-authentication-signing-launcher-private-key.pem")
}
Expand Down
39 changes: 19 additions & 20 deletions surveys/surveys.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ func FindSurveyByName(name string) LauncherSchema {

func GetSupplementaryDataSets(surveyId string, periodId string) ([]DatasetMetadata, error) {
datasetList := []DatasetMetadata{}
hostURL := settings.Get("SDS_API_URL")
log.Printf("SDS Api URL: %s", hostURL)
hostURL := settings.Get("SDS_API_BASE_URL")
log.Printf("SDS API Base URL: %s", hostURL)
url := fmt.Sprintf("%s/v1/dataset_metadata?survey_id=%s&period_id=%s", hostURL, surveyId, periodId)
resp, err := clients.GetHTTPClient().Get(url)

if err != nil || (resp.StatusCode != 200 && resp.StatusCode != 404){
if err != nil || (resp.StatusCode != 200 && resp.StatusCode != 404) {
return datasetList, errors.New("unable to fetch supplementary data")
}
if resp.StatusCode == 404 {
Expand All @@ -214,21 +214,20 @@ func GetSupplementaryDataSets(surveyId string, periodId string) ([]DatasetMetada

// Return a LauncherSchema instance by loading schema from name or URL
func GetLauncherSchema(schemaName string, schemaUrl string) LauncherSchema {
var launcherSchema LauncherSchema

if schemaUrl != "" {
log.Println("Getting schema by URL: " + schemaUrl)
launcherSchema = LauncherSchema {
URL: schemaUrl,
Name: schemaName,
}
} else if schemaName != "" {
log.Println("Searching for schema by name: " + schemaName)
launcherSchema = FindSurveyByName(schemaName)
} else {
panic("Either `schema_name` or `schema_url` must be provided.")
}

return launcherSchema
}
var launcherSchema LauncherSchema

if schemaUrl != "" {
log.Println("Getting schema by URL: " + schemaUrl)
launcherSchema = LauncherSchema{
URL: schemaUrl,
Name: schemaName,
}
} else if schemaName != "" {
log.Println("Searching for schema by name: " + schemaName)
launcherSchema = FindSurveyByName(schemaName)
} else {
panic("Either `schema_name` or `schema_url` must be provided.")
}

return launcherSchema
}

0 comments on commit 814d206

Please sign in to comment.