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

Aligning SDS API Base URL naming with runner #51

Merged
merged 1 commit into from
Jul 21, 2023
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
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
}