Skip to content

Commit

Permalink
fix: set env vars correctly according to new subdomain/region scheme (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop authored Aug 21, 2024
1 parent 4294c19 commit 36c4946
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 18 deletions.
6 changes: 6 additions & 0 deletions dockercompose/ai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func expectedAI() *Service {
"dev.graphql.local.nhost.run:host-gateway",
"dev.hasura.local.nhost.run:host-gateway",
"dev.storage.local.nhost.run:host-gateway",
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
},
HealthCheck: &HealthCheck{
Test: []string{"CMD", "graphite", "healthcheck"},
Expand Down
6 changes: 6 additions & 0 deletions dockercompose/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ func expectedAuth() *Service {
"dev.graphql.local.nhost.run:host-gateway",
"dev.hasura.local.nhost.run:host-gateway",
"dev.storage.local.nhost.run:host-gateway",
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
},
HealthCheck: &HealthCheck{
Test: []string{"CMD", "wget", "--spider", "-S", "http://localhost:4000/healthz"},
Expand Down
13 changes: 11 additions & 2 deletions dockercompose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ func extraHosts(subdomain string) []string {
subdomain + ".graphql.local.nhost.run:host-gateway",
subdomain + ".hasura.local.nhost.run:host-gateway",
subdomain + ".storage.local.nhost.run:host-gateway",
// below entries shouldn't be needed unless
// users are hardcoding these subdomains
// adding out of an abundance of caution
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
}
}

Expand Down Expand Up @@ -354,8 +363,8 @@ func functions( //nolint:funlen
"NHOST_HASURA_URL": URL(subdomain, "hasura", httpPort, useTLS) + "/console",
"NHOST_STORAGE_URL": URL(subdomain, "storage", httpPort, useTLS) + "/v1",
"NHOST_JWT_SECRET": jwtSecret,
"NHOST_REGION": "",
"NHOST_SUBDOMAIN": "local",
"NHOST_REGION": "local",
"NHOST_SUBDOMAIN": subdomain,
"NHOST_WEBHOOK_SECRET": cfg.Hasura.WebhookSecret,
"GRAPHITE_WEBHOOK_SECRET": cfg.GetAi().GetWebhookSecret(),
}
Expand Down
4 changes: 2 additions & 2 deletions dockercompose/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func graphql( //nolint:funlen
) (*Service, error) {
envars, err := appconfig.HasuraEnv(
cfg,
subdomain,
"local",
"",
"nhost.run",
"postgres://nhost_hasura@postgres:5432/local",
useTLS,
Expand Down Expand Up @@ -107,8 +107,8 @@ func console( //nolint:funlen

envars, err := appconfig.HasuraEnv(
cfg,
subdomain,
"local",
"",
"nhost.run",
"postgres://nhost_hasura@postgres:5432/local",
useTLS,
Expand Down
40 changes: 26 additions & 14 deletions dockercompose/graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ func expectedGraphql() *Service {
"HASURA_GRAPHQL_USE_PREPARED_STATEMENTS": "true",
"HASURA_GRAPHQL_WS_READ_COOKIE": "false",
"NHOST_ADMIN_SECRET": "adminSecret",
"NHOST_AUTH_URL": "http://local.auth.nhost.run:1337/v1",
"NHOST_FUNCTIONS_URL": "http://local.functions.nhost.run:1337/v1",
"NHOST_GRAPHQL_URL": "http://local.graphql.nhost.run:1337/v1",
"NHOST_HASURA_URL": "http://local.hasura.nhost.run:1337",
"NHOST_AUTH_URL": "http://dev.auth.local.nhost.run:1337/v1",
"NHOST_FUNCTIONS_URL": "http://dev.functions.local.nhost.run:1337/v1",
"NHOST_GRAPHQL_URL": "http://dev.graphql.local.nhost.run:1337/v1",
"NHOST_HASURA_URL": "http://dev.hasura.local.nhost.run:1337",
"NHOST_JWT_SECRET": `{"claims_map":{"x-hasura-allowed-roles":{"path":"$.roles"},"x-hasura-default-role":"viewer","x-hasura-org-id":{"default":"public","path":"$.org"},"x-hasura-user-id":{"path":"$.sub"}},"key":"jwtSecretKey","type":"HS256"}`,
"NHOST_REGION": "",
"NHOST_STORAGE_URL": "http://local.storage.nhost.run:1337/v1",
"NHOST_SUBDOMAIN": "local",
"NHOST_REGION": "local",
"NHOST_STORAGE_URL": "http://dev.storage.local.nhost.run:1337/v1",
"NHOST_SUBDOMAIN": "dev",
"NHOST_WEBHOOK_SECRET": "webhookSecret",
},
ExtraHosts: []string{
Expand All @@ -64,6 +64,12 @@ func expectedGraphql() *Service {
"dev.graphql.local.nhost.run:host-gateway",
"dev.hasura.local.nhost.run:host-gateway",
"dev.storage.local.nhost.run:host-gateway",
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
},
HealthCheck: &HealthCheck{
Test: []string{
Expand Down Expand Up @@ -178,14 +184,14 @@ func expectedConsole() *Service {
"HASURA_GRAPHQL_USE_PREPARED_STATEMENTS": "true",
"HASURA_GRAPHQL_WS_READ_COOKIE": "false",
"NHOST_ADMIN_SECRET": "adminSecret",
"NHOST_AUTH_URL": "http://local.auth.nhost.run:1337/v1",
"NHOST_FUNCTIONS_URL": "http://local.functions.nhost.run:1337/v1",
"NHOST_GRAPHQL_URL": "http://local.graphql.nhost.run:1337/v1",
"NHOST_HASURA_URL": "http://local.hasura.nhost.run:1337",
"NHOST_AUTH_URL": "http://dev.auth.local.nhost.run:1337/v1",
"NHOST_FUNCTIONS_URL": "http://dev.functions.local.nhost.run:1337/v1",
"NHOST_GRAPHQL_URL": "http://dev.graphql.local.nhost.run:1337/v1",
"NHOST_HASURA_URL": "http://dev.hasura.local.nhost.run:1337",
"NHOST_JWT_SECRET": `{"claims_map":{"x-hasura-allowed-roles":{"path":"$.roles"},"x-hasura-default-role":"viewer","x-hasura-org-id":{"default":"public","path":"$.org"},"x-hasura-user-id":{"path":"$.sub"}},"key":"jwtSecretKey","type":"HS256"}`, //nolint:lll
"NHOST_REGION": "",
"NHOST_STORAGE_URL": "http://local.storage.nhost.run:1337/v1",
"NHOST_SUBDOMAIN": "local",
"NHOST_REGION": "local",
"NHOST_STORAGE_URL": "http://dev.storage.local.nhost.run:1337/v1",
"NHOST_SUBDOMAIN": "dev",
"NHOST_WEBHOOK_SECRET": "webhookSecret",
},
ExtraHosts: []string{
Expand All @@ -196,6 +202,12 @@ func expectedConsole() *Service {
"dev.graphql.local.nhost.run:host-gateway",
"dev.hasura.local.nhost.run:0.0.0.0",
"dev.storage.local.nhost.run:host-gateway",
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
},
HealthCheck: &HealthCheck{
Test: []string{
Expand Down
6 changes: 6 additions & 0 deletions dockercompose/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func expectedPostgres(tmpdir string) *Service {
"dev.graphql.local.nhost.run:host-gateway",
"dev.hasura.local.nhost.run:host-gateway",
"dev.storage.local.nhost.run:host-gateway",
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
},
HealthCheck: &HealthCheck{
Test: []string{"CMD-SHELL", "pg_isready -U postgres", "-d", "postgres", "-q"},
Expand Down
6 changes: 6 additions & 0 deletions dockercompose/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ func TestRun(t *testing.T) {
"dev.graphql.local.nhost.run:host-gateway",
"dev.hasura.local.nhost.run:host-gateway",
"dev.storage.local.nhost.run:host-gateway",
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
},
Labels: map[string]string{},
Ports: []Port{
Expand Down
6 changes: 6 additions & 0 deletions dockercompose/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func expectedStorage() *Service {
"dev.graphql.local.nhost.run:host-gateway",
"dev.hasura.local.nhost.run:host-gateway",
"dev.storage.local.nhost.run:host-gateway",
"local.auth.nhost.run:host-gateway",
"local.db.nhost.run:host-gateway",
"local.functions.nhost.run:host-gateway",
"local.graphql.nhost.run:host-gateway",
"local.hasura.nhost.run:host-gateway",
"local.storage.nhost.run:host-gateway",
},
HealthCheck: nil,
Labels: map[string]string{
Expand Down

0 comments on commit 36c4946

Please sign in to comment.