( //nolint:funlen cfg *model.ConfigConfig, subdomain string, httpPort uint, useTLS bool, rootFolder string, jwtSecret string, port uint, branch string, functionsVersion string, )
| 441 | } |
| 442 | |
| 443 | func functions( //nolint:funlen |
| 444 | cfg *model.ConfigConfig, |
| 445 | subdomain string, |
| 446 | httpPort uint, |
| 447 | useTLS bool, |
| 448 | rootFolder string, |
| 449 | jwtSecret string, |
| 450 | port uint, |
| 451 | branch string, |
| 452 | functionsVersion string, |
| 453 | ) (*Service, error) { |
| 454 | jwtSecret, err := stripJWTSecretToPublic(jwtSecret) |
| 455 | if err != nil { |
| 456 | return nil, fmt.Errorf("failed to strip JWT secret for %s: %w", "functions", err) |
| 457 | } |
| 458 | |
| 459 | envVars := map[string]string{ |
| 460 | "HASURA_GRAPHQL_ADMIN_SECRET": cfg.Hasura.AdminSecret, |
| 461 | "HASURA_GRAPHQL_DATABASE_URL": "postgres://nhost_auth_admin@local.db.nhost.run:5432/local", |
| 462 | "HASURA_GRAPHQL_GRAPHQL_URL": "http://graphql:8080/v1/graphql", |
| 463 | "HASURA_GRAPHQL_JWT_SECRET": jwtSecret, |
| 464 | "NHOST_ADMIN_SECRET": cfg.Hasura.AdminSecret, |
| 465 | "NHOST_AUTH_URL": URL(subdomain, "auth", httpPort, useTLS) + "/v1", |
| 466 | "NHOST_FUNCTIONS_URL": URL(subdomain, "functions", httpPort, useTLS) + "/v1", |
| 467 | "NHOST_GRAPHQL_URL": URL(subdomain, "graphql", httpPort, useTLS) + "/v1", |
| 468 | "NHOST_HASURA_URL": URL(subdomain, "hasura", httpPort, useTLS) + "/console", |
| 469 | "NHOST_STORAGE_URL": URL(subdomain, "storage", httpPort, useTLS) + "/v1", |
| 470 | "NHOST_JWT_SECRET": jwtSecret, |
| 471 | "NHOST_REGION": "local", |
| 472 | "NHOST_SUBDOMAIN": subdomain, |
| 473 | "NHOST_WEBHOOK_SECRET": cfg.Hasura.WebhookSecret, |
| 474 | "GRAPHITE_WEBHOOK_SECRET": cfg.GetAi().GetWebhookSecret(), |
| 475 | } |
| 476 | for _, envVar := range cfg.GetGlobal().GetEnvironment() { |
| 477 | envVars[envVar.GetName()] = envVar.GetValue() |
| 478 | } |
| 479 | |
| 480 | return &Service{ |
| 481 | Image: fmt.Sprintf( |
| 482 | "nhost/functions:%d-%s", |
| 483 | *cfg.GetFunctions().GetNode().Version, |
| 484 | functionsVersion, |
| 485 | ), |
| 486 | DependsOn: nil, |
| 487 | EntryPoint: nil, |
| 488 | Command: nil, |
| 489 | Environment: envVars, |
| 490 | ExtraHosts: extraHosts(subdomain), |
| 491 | HealthCheck: &HealthCheck{ |
| 492 | Test: []string{"CMD", "wget", "--spider", "-S", "http://localhost:3000/healthz"}, |
| 493 | Interval: "5s", |
| 494 | Timeout: "600s", |
| 495 | StartPeriod: "600s", |
| 496 | }, |
| 497 | Labels: Ingresses{ |
| 498 | { |
| 499 | Name: "functions", |
| 500 | TLS: useTLS, |
no test coverage detected