Skip to content

Commit 08a8384

Browse files
authored
Merge pull request #405 from voxel51/add-external-api-url
feat: add API_EXTERNAL_URL
2 parents 971c245 + 4ffbed1 commit 08a8384

10 files changed

Lines changed: 131 additions & 6 deletions

File tree

docker/common-services.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ services:
3434
teams-api-common:
3535
image: voxel51/fiftyone-teams-api:v2.11.0
3636
environment:
37+
API_EXTERNAL_URL: ${FIFTYONE_API_URI}
3738
CAS_BASE_URL: ${CAS_BASE_URL:-http://teams-cas:3000/cas/api}
3839
FIFTYONE_AUTH_SECRET: ${FIFTYONE_AUTH_SECRET}
3940
FIFTYONE_DATABASE_NAME: ${FIFTYONE_DATABASE_NAME}

docker/internal-auth/env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This should be the URL your end-users will connect to
22
BASE_URL=https://example.fiftyone.ai
33

4-
# This should be set to the URI your end-users will use to connect to the API
4+
# This should be set to the URI your end-users and external orchestrators will use to connect to the API
55
# This could be the same as BASE_URL if you are using path-based routing
66
FIFTYONE_API_URI=https://example-api.fiftyone.ai
77

docker/legacy-auth/env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ AUTH0_SECRET=
44
# This should be the URL your end-users will connect to
55
AUTH0_BASE_URL=https://example.fiftyone.ai
66

7-
# This should be set to the URI your end-users will use to connect to the API
7+
# This should be set to the URI your end-users and external orchestrators will use to connect to the API
88
# This could be the same as AUTH0_BASE_URL if you are using path-based routing
99
FIFTYONE_API_URI=https://example-api.fiftyone.ai
1010

helm/fiftyone-teams-app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ follow
480480
|-----|------|---------|-------------|
481481
| apiSettings.affinity | object | `{}` | Affinity and anti-affinity for `teams-api`. [Reference][affinity]. |
482482
| apiSettings.deploymentAnnotations | object | `{}` | Annotations for the `teams-api` deployment. [Reference][annotations]. |
483-
| apiSettings.dnsName | string | `""` | Controls whether `teams-api` is added to the chart's ingress. When an empty string, a rule for `teams-api` is not added to the chart managed ingress. When not an empty string, becomes the value to the `host` in the ingress' rule and set `ingress.api` too. |
483+
| apiSettings.dnsName | string | `""` | Controls whether `teams-api` is added to the chart's ingress. When an empty string, a rule for `teams-api` is not added to the chart managed ingress. When not an empty string, becomes the value to the `host` in the ingress' rule and set `ingress.api` too. Additionally, the `apiSettings.dnsName` is used by `teams-api` to generate the `API_EXTERNAL_URL` environment variable for configuring external orchestrators. |
484484
| apiSettings.env.FIFTYONE_ENV | string | `"production"` | Controls FiftyOne GraphQL verbosity. When "production", debug mode is disabled and the default logging level is "INFO". When "development", debug mode is enabled and the default logging level is "DEBUG". Can be overridden by setting `apiSettings.env.LOGGING_LEVEL`. |
485485
| apiSettings.env.FIFTYONE_INTERNAL_SERVICE | bool | `true` | Whether the SDK is running in an internal service context. When running in FiftyOne Enterprise, set to `true`. |
486486
| apiSettings.env.FIFTYONE_LOGGING_FORMAT | string | `"text"` | The format to use for log messages. Can be one of `json` or `text`. |

helm/fiftyone-teams-app/templates/_helpers.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ Create a merged list of environment variables for fiftyone-teams-api
337337
*/}}
338338
{{- define "fiftyone-teams-api.env-vars-list" -}}
339339
{{- $secretName := .Values.secret.name }}
340+
- name: API_EXTERNAL_URL
341+
{{- if .Values.apiSettings.dnsName }}
342+
value: {{ printf "https://%s" .Values.apiSettings.dnsName | quote}}
343+
{{- else if .Values.teamsAppSettings.dnsName }}
344+
value: {{ printf "https://%s" .Values.teamsAppSettings.dnsName | quote }}
345+
{{- else }}
346+
value: ""
347+
{{- end }}
340348
- name: CAS_BASE_URL
341349
value: {{ printf "http://%s:%.0f/cas/api" .Values.casSettings.service.name (float64 .Values.casSettings.service.port) | quote }}
342350
- name: FIFTYONE_AUTH_SECRET

helm/fiftyone-teams-app/values.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"dnsName": {
2020
"default": "",
21-
"description": "Controls whether `teams-api` is added to the chart's ingress.\nWhen an empty string, a rule for `teams-api` is not added to the chart managed ingress.\nWhen not an empty string, becomes the value to the `host` in the ingress' rule and\nset `ingress.api` too.",
21+
"description": "Controls whether `teams-api` is added to the chart's ingress.\nWhen an empty string, a rule for `teams-api` is not added to the chart managed ingress.\nWhen not an empty string, becomes the value to the `host` in the ingress' rule and\nset `ingress.api` too. Additionally, the `apiSettings.dnsName` is used by `teams-api`\nto generate the `API_EXTERNAL_URL` environment variable for configuring external orchestrators.",
2222
"required": [],
2323
"title": "dnsName",
2424
"type": "string"

helm/fiftyone-teams-app/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ apiSettings:
55
# -- Controls whether `teams-api` is added to the chart's ingress.
66
# When an empty string, a rule for `teams-api` is not added to the chart managed ingress.
77
# When not an empty string, becomes the value to the `host` in the ingress' rule and
8-
# set `ingress.api` too.
8+
# set `ingress.api` too. Additionally, the `apiSettings.dnsName` is used by `teams-api`
9+
# to generate the `API_EXTERNAL_URL` environment variable for configuring external orchestrators.
910
dnsName: ""
1011
# -- Annotations for the `teams-api` deployment. [Reference][annotations].
1112
deploymentAnnotations: {}

tests/unit/compose/docker-compose-internal-auth_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ func (s *commonServicesInternalAuthDockerComposeTest) TestServiceEnvironment() {
258258
[]string{internalAuthComposeFile},
259259
s.dotEnvFiles,
260260
[]string{
261+
"API_EXTERNAL_URL=https://example-api.fiftyone.ai",
261262
"CAS_BASE_URL=http://teams-cas:3000/cas/api",
262263
"FIFTYONE_AUTH_SECRET=test-fiftyone-auth-secret",
263264
"FIFTYONE_DATABASE_NAME=fiftyone",
@@ -340,6 +341,7 @@ func (s *commonServicesInternalAuthDockerComposeTest) TestServiceEnvironment() {
340341
[]string{internalAuthComposePluginsFile},
341342
s.dotEnvFiles,
342343
[]string{
344+
"API_EXTERNAL_URL=https://example-api.fiftyone.ai",
343345
"CAS_BASE_URL=http://teams-cas:3000/cas/api",
344346
"FIFTYONE_AUTH_SECRET=test-fiftyone-auth-secret",
345347
"FIFTYONE_DATABASE_NAME=fiftyone",
@@ -422,6 +424,7 @@ func (s *commonServicesInternalAuthDockerComposeTest) TestServiceEnvironment() {
422424
[]string{internalAuthComposeDedicatedPluginsFile},
423425
s.dotEnvFiles,
424426
[]string{
427+
"API_EXTERNAL_URL=https://example-api.fiftyone.ai",
425428
"CAS_BASE_URL=http://teams-cas:3000/cas/api",
426429
"FIFTYONE_AUTH_SECRET=test-fiftyone-auth-secret",
427430
"FIFTYONE_DATABASE_NAME=fiftyone",

tests/unit/compose/docker-compose-legacy-auth_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
var legacyAuthComposeFile = filepath.Join(dockerLegacyAuthDir, "compose.yaml")
2828
var legacyAuthComposePluginsFile = filepath.Join(dockerLegacyAuthDir, "compose.plugins.yaml")
2929
var legacyAuthComposeDedicatedPluginsFile = filepath.Join(dockerLegacyAuthDir, "compose.dedicated-plugins.yaml")
30-
var legacyAuthComposeDelegatedOperationsFile = filepath.Join(dockerInternalAuthDir, "compose.delegated-operators.yaml")
30+
var legacyAuthComposeDelegatedOperationsFile = filepath.Join(dockerLegacyAuthDir, "compose.delegated-operators.yaml")
3131
var legacyAuthEnvTemplateFilePath = filepath.Join(dockerLegacyAuthDir, "env.template")
3232

3333
type commonServicesLegacyAuthDockerComposeTest struct {
@@ -258,6 +258,7 @@ func (s *commonServicesLegacyAuthDockerComposeTest) TestServiceEnvironment() {
258258
[]string{legacyAuthComposeFile},
259259
s.dotEnvFiles,
260260
[]string{
261+
"API_EXTERNAL_URL=https://example-api.fiftyone.ai",
261262
"CAS_BASE_URL=http://teams-cas:3000/cas/api",
262263
"FIFTYONE_AUTH_SECRET=test-fiftyone-auth-secret",
263264
"FIFTYONE_DATABASE_NAME=fiftyone",
@@ -338,6 +339,7 @@ func (s *commonServicesLegacyAuthDockerComposeTest) TestServiceEnvironment() {
338339
[]string{legacyAuthComposeFile},
339340
s.dotEnvFiles,
340341
[]string{
342+
"API_EXTERNAL_URL=https://example-api.fiftyone.ai",
341343
"CAS_BASE_URL=http://teams-cas:3000/cas/api",
342344
"FIFTYONE_AUTH_SECRET=test-fiftyone-auth-secret",
343345
"FIFTYONE_DATABASE_NAME=fiftyone",
@@ -419,6 +421,7 @@ func (s *commonServicesLegacyAuthDockerComposeTest) TestServiceEnvironment() {
419421
[]string{legacyAuthComposePluginsFile},
420422
s.dotEnvFiles,
421423
[]string{
424+
"API_EXTERNAL_URL=https://example-api.fiftyone.ai",
422425
"CAS_BASE_URL=http://teams-cas:3000/cas/api",
423426
"FIFTYONE_AUTH_SECRET=test-fiftyone-auth-secret",
424427
"FIFTYONE_DATABASE_NAME=fiftyone",
@@ -500,6 +503,7 @@ func (s *commonServicesLegacyAuthDockerComposeTest) TestServiceEnvironment() {
500503
[]string{legacyAuthComposeDedicatedPluginsFile},
501504
s.dotEnvFiles,
502505
[]string{
506+
"API_EXTERNAL_URL=https://example-api.fiftyone.ai",
503507
"CAS_BASE_URL=http://teams-cas:3000/cas/api",
504508
"FIFTYONE_AUTH_SECRET=test-fiftyone-auth-secret",
505509
"FIFTYONE_DATABASE_NAME=fiftyone",

tests/unit/helm/api-deployment_test.go

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ func (s *deploymentApiTemplateTest) TestContainerEnv() {
433433
nil,
434434
func(envVars []corev1.EnvVar) {
435435
expectedEnvVarJSON := `[
436+
{
437+
"name": "API_EXTERNAL_URL",
438+
"value": ""
439+
},
436440
{
437441
"name": "CAS_BASE_URL",
438442
"value": "http://teams-cas:80/cas/api"
@@ -518,6 +522,10 @@ func (s *deploymentApiTemplateTest) TestContainerEnv() {
518522
},
519523
func(envVars []corev1.EnvVar) {
520524
expectedEnvVarJSON := `[
525+
{
526+
"name": "API_EXTERNAL_URL",
527+
"value": ""
528+
},
521529
{
522530
"name": "CAS_BASE_URL",
523531
"value": "http://teams-cas:80/cas/api"
@@ -617,6 +625,10 @@ func (s *deploymentApiTemplateTest) TestContainerEnv() {
617625
},
618626
func(envVars []corev1.EnvVar) {
619627
expectedEnvVarJSON := `[
628+
{
629+
"name": "API_EXTERNAL_URL",
630+
"value": ""
631+
},
620632
{
621633
"name": "CAS_BASE_URL",
622634
"value": "http://teams-cas:80/cas/api"
@@ -713,6 +725,10 @@ func (s *deploymentApiTemplateTest) TestContainerEnv() {
713725
},
714726
func(envVars []corev1.EnvVar) {
715727
expectedEnvVarJSON := `[
728+
{
729+
"name": "API_EXTERNAL_URL",
730+
"value": ""
731+
},
716732
{
717733
"name": "CAS_BASE_URL",
718734
"value": "http://teams-cas:80/cas/api"
@@ -797,6 +813,10 @@ func (s *deploymentApiTemplateTest) TestContainerEnv() {
797813
},
798814
func(envVars []corev1.EnvVar) {
799815
expectedEnvVarJSON := `[
816+
{
817+
"name": "API_EXTERNAL_URL",
818+
"value": ""
819+
},
800820
{
801821
"name": "CAS_BASE_URL",
802822
"value": "http://teams-cas-override:8000/cas/api"
@@ -866,6 +886,94 @@ func (s *deploymentApiTemplateTest) TestContainerEnv() {
866886
"name": "LOGGING_LEVEL",
867887
"value": "INFO"
868888
}
889+
]`
890+
var expectedEnvVars []corev1.EnvVar
891+
err := json.Unmarshal([]byte(expectedEnvVarJSON), &expectedEnvVars)
892+
s.NoError(err)
893+
s.Equal(expectedEnvVars, envVars, "Envs should be equal")
894+
},
895+
},
896+
{
897+
"overrideExternalApiUrl",
898+
map[string]string{
899+
"apiSettings.dnsName": "external-api-url:443",
900+
"teamsAppSettings.dnsName": "external-app-url:443",
901+
},
902+
func(envVars []corev1.EnvVar) {
903+
expectedEnvVarJSON := `[
904+
{
905+
"name": "API_EXTERNAL_URL",
906+
"value": "https://external-api-url:443"
907+
},
908+
{
909+
"name": "CAS_BASE_URL",
910+
"value": "http://teams-cas:80/cas/api"
911+
},
912+
{
913+
"name": "FIFTYONE_AUTH_SECRET",
914+
"valueFrom": {
915+
"secretKeyRef": {
916+
"name": "fiftyone-teams-secrets",
917+
"key": "fiftyoneAuthSecret"
918+
}
919+
}
920+
},
921+
{
922+
"name": "FIFTYONE_DATABASE_NAME",
923+
"valueFrom": {
924+
"secretKeyRef": {
925+
"name": "fiftyone-teams-secrets",
926+
"key": "fiftyoneDatabaseName"
927+
}
928+
}
929+
},
930+
{
931+
"name": "FIFTYONE_DATABASE_URI",
932+
"valueFrom": {
933+
"secretKeyRef": {
934+
"name": "fiftyone-teams-secrets",
935+
"key": "mongodbConnectionString"
936+
}
937+
}
938+
},
939+
{
940+
"name": "FIFTYONE_ENCRYPTION_KEY",
941+
"valueFrom": {
942+
"secretKeyRef": {
943+
"name": "fiftyone-teams-secrets",
944+
"key": "encryptionKey"
945+
}
946+
}
947+
},
948+
{
949+
"name": "MONGO_DEFAULT_DB",
950+
"valueFrom": {
951+
"secretKeyRef": {
952+
"name": "fiftyone-teams-secrets",
953+
"key": "fiftyoneDatabaseName"
954+
}
955+
}
956+
},
957+
{
958+
"name": "FIFTYONE_ENV",
959+
"value": "production"
960+
},
961+
{
962+
"name": "FIFTYONE_INTERNAL_SERVICE",
963+
"value": "true"
964+
},
965+
{
966+
"name": "FIFTYONE_LOGGING_FORMAT",
967+
"value": "text"
968+
},
969+
{
970+
"name": "GRAPHQL_DEFAULT_LIMIT",
971+
"value": "10"
972+
},
973+
{
974+
"name": "LOGGING_LEVEL",
975+
"value": "INFO"
976+
}
869977
]`
870978
var expectedEnvVars []corev1.EnvVar
871979
err := json.Unmarshal([]byte(expectedEnvVarJSON), &expectedEnvVars)

0 commit comments

Comments
 (0)