diff --git a/cmd/config/example.go b/cmd/config/example.go index 52a2bb402..4d460ebbf 100644 --- a/cmd/config/example.go +++ b/cmd/config/example.go @@ -72,7 +72,7 @@ func commandExample(cCtx *cli.Context) error { //nolint:funlen,maintidx }, Functions: &model.ConfigFunctions{ Node: &model.ConfigFunctionsNode{ - Version: ptr(int(16)), + Version: ptr(int(18)), }, }, Auth: &model.ConfigAuth{ @@ -266,6 +266,7 @@ func commandExample(cCtx *cli.Context) error { //nolint:funlen,maintidx Replicas: 1, }, Settings: &model.ConfigPostgresSettings{ + Jit: ptr("off"), MaxConnections: ptr(int32(100)), SharedBuffers: ptr("128MB"), EffectiveCacheSize: ptr("4GB"), diff --git a/cmd/config/testdata/validate/success/nhost/nhost.toml b/cmd/config/testdata/validate/success/nhost/nhost.toml index 499ee4833..a5ef4ea2d 100644 --- a/cmd/config/testdata/validate/success/nhost/nhost.toml +++ b/cmd/config/testdata/validate/success/nhost/nhost.toml @@ -28,7 +28,7 @@ httpPoolSize = 100 [functions] [functions.node] -version = 16 +version = 18 [auth] version = '0.20.0' diff --git a/cmd/config/validate_test.go b/cmd/config/validate_test.go index f0d073b7c..d45029ab9 100644 --- a/cmd/config/validate_test.go +++ b/cmd/config/validate_test.go @@ -51,7 +51,7 @@ func expectedConfig() *model.ConfigConfig { Logs: &model.ConfigHasuraLogs{Level: ptr("warn")}, Events: &model.ConfigHasuraEvents{HttpPoolSize: ptr(uint32(100))}, }, - Functions: &model.ConfigFunctions{Node: &model.ConfigFunctionsNode{Version: ptr(16)}}, + Functions: &model.ConfigFunctions{Node: &model.ConfigFunctionsNode{Version: ptr(18)}}, Auth: &model.ConfigAuth{ Version: ptr("0.20.0"), Redirections: &model.ConfigAuthRedirections{ diff --git a/cmd/dev/up.go b/cmd/dev/up.go index 79376b07b..547a6f460 100644 --- a/cmd/dev/up.go +++ b/cmd/dev/up.go @@ -25,7 +25,6 @@ const ( flagsFunctionsPort = "functions-port" flagsHasuraPort = "hasura-port" flagsHasuraConsolePort = "hasura-console-port" - flagsNode18 = "node18" ) const ( @@ -33,7 +32,7 @@ const ( defaultPostgresPort = 5432 ) -func CommandUp() *cli.Command { //nolint:funlen +func CommandUp() *cli.Command { return &cli.Command{ //nolint:exhaustruct Name: "up", Aliases: []string{}, @@ -89,11 +88,6 @@ func CommandUp() *cli.Command { //nolint:funlen Usage: "If specified, expose hasura console on this port. Not recommended", Value: 0, }, - &cli.BoolFlag{ //nolint:exhaustruct - Name: flagsNode18, - Usage: "Use node 18. Defaults to node 16", - Value: false, - }, }, } } @@ -129,7 +123,6 @@ func commandUp(cCtx *cli.Context) error { Console: cCtx.Uint(flagsHasuraConsolePort), Functions: cCtx.Uint(flagsFunctionsPort), }, - cCtx.Bool(flagsNode18), ) } @@ -187,7 +180,6 @@ func up( //nolint:funlen postgresPort uint, applySeeds bool, ports dockercompose.ExposePorts, - useNode18 bool, ) error { ctx, cancel := context.WithCancel(ctx) @@ -215,7 +207,6 @@ func up( //nolint:funlen ce.Path.DotNhostFolder(), ce.Path.Root(), ports, - useNode18, ) if err != nil { return fmt.Errorf("failed to generate docker-compose.yaml: %w", err) @@ -287,12 +278,11 @@ func Up( postgresPort uint, applySeeds bool, ports dockercompose.ExposePorts, - useNode18 bool, ) error { dc := dockercompose.New(ce.Path.WorkingDir(), ce.Path.DockerCompose(), ce.ProjectName()) if err := up( - ctx, ce, dc, httpPort, useTLS, postgresPort, applySeeds, ports, useNode18, + ctx, ce, dc, httpPort, useTLS, postgresPort, applySeeds, ports, ); err != nil { ce.Warnln(err.Error()) diff --git a/dockercompose/compose.go b/dockercompose/compose.go index 3bd54bf81..0268f195c 100644 --- a/dockercompose/compose.go +++ b/dockercompose/compose.go @@ -297,7 +297,6 @@ func functions( //nolint:funlen rootFolder string, jwtSecret string, port uint, - useNode18 bool, ) *Service { envVars := map[string]string{ "HASURA_GRAPHQL_ADMIN_SECRET": cfg.Hasura.AdminSecret, @@ -319,13 +318,8 @@ func functions( //nolint:funlen envVars[envVar.GetName()] = envVar.GetValue() } - image := "nhost/functions:0.1.9" - if useNode18 { - image = "nhost/functions:1.0.0" - } - return &Service{ - Image: image, + Image: "nhost/functions:1.0.0", DependsOn: nil, EntryPoint: nil, Command: nil, @@ -434,7 +428,6 @@ func ComposeFileFromConfig( //nolint:funlen dotNhostFolder string, rootFolder string, ports ExposePorts, - useNode18 bool, ) (*ComposeFile, error) { minio, err := minio(dataFolder) if err != nil { @@ -490,7 +483,6 @@ func ComposeFileFromConfig( //nolint:funlen rootFolder, jwtSecret, ports.Functions, - useNode18, ), "graphql": graphql, "minio": minio, diff --git a/dockercompose/main_test.go b/dockercompose/main_test.go index b97d0e3ad..ae1b66bf2 100644 --- a/dockercompose/main_test.go +++ b/dockercompose/main_test.go @@ -197,7 +197,7 @@ func getConfig() *model.ConfigConfig { //nolint:maintidx }, Functions: &model.ConfigFunctions{ Node: &model.ConfigFunctionsNode{ - Version: ptr(16), + Version: ptr(18), }, }, Hasura: &model.ConfigHasura{ diff --git a/examples/myproject/nhost/nhost.toml b/examples/myproject/nhost/nhost.toml index 396045e54..abf07a0a8 100644 --- a/examples/myproject/nhost/nhost.toml +++ b/examples/myproject/nhost/nhost.toml @@ -23,7 +23,7 @@ liveQueriesMultiplexedRefetchInterval = 3000 [functions] [functions.node] -version = 16 +version = 18 [auth] version = '0.21.2' diff --git a/go.mod b/go.mod index 6fe4dbd88..86e26d5bb 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/go-git/go-git/v5 v5.9.0 github.com/google/go-cmp v0.5.9 github.com/hashicorp/go-getter v1.7.2 - github.com/nhost/be v0.0.0-20230927103250-70010e0e7eac + github.com/nhost/be v0.0.0-20231001065154-f72edc119cf0 github.com/pelletier/go-toml/v2 v2.0.8 github.com/urfave/cli/v2 v2.25.7 github.com/wI2L/jsondiff v0.4.0 diff --git a/go.sum b/go.sum index fa64d8eaa..6464c390d 100644 --- a/go.sum +++ b/go.sum @@ -441,10 +441,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= -github.com/nhost/be v0.0.0-20230926093342-5b218de2929f h1:Ws9TS33VKX3w+36k18utttmAeiwFQQBNwEpTz7vLJYU= -github.com/nhost/be v0.0.0-20230926093342-5b218de2929f/go.mod h1:TX+opGjg0+Q7LflEByl4E8B8hlu1huf4t2TY3YzUA9c= -github.com/nhost/be v0.0.0-20230927103250-70010e0e7eac h1:yCWxfY84DgC5oQYjFJ3s1YJ54jKphlLJlIIIRtXwbv4= -github.com/nhost/be v0.0.0-20230927103250-70010e0e7eac/go.mod h1:TX+opGjg0+Q7LflEByl4E8B8hlu1huf4t2TY3YzUA9c= +github.com/nhost/be v0.0.0-20231001065154-f72edc119cf0 h1:cKSejJFrMjUBamyWotU1fTxU8Y7SCvkRL1bt03uMIyA= +github.com/nhost/be v0.0.0-20231001065154-f72edc119cf0/go.mod h1:TX+opGjg0+Q7LflEByl4E8B8hlu1huf4t2TY3YzUA9c= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= diff --git a/vendor/github.com/nhost/be/services/mimir/model/cuegraph_gen.go b/vendor/github.com/nhost/be/services/mimir/model/cuegraph_gen.go index fdfaa3d3e..9c1fc56df 100644 --- a/vendor/github.com/nhost/be/services/mimir/model/cuegraph_gen.go +++ b/vendor/github.com/nhost/be/services/mimir/model/cuegraph_gen.go @@ -11673,6 +11673,8 @@ func (exp *ConfigPostgresComparisonExp) Matches(o *ConfigPostgres) bool { } type ConfigPostgresSettings struct { + Jit *string `json:"jit" toml:"jit"` + MaxConnections *int32 `json:"maxConnections" toml:"maxConnections"` SharedBuffers *string `json:"sharedBuffers" toml:"sharedBuffers"` @@ -11710,6 +11712,9 @@ type ConfigPostgresSettings struct { func (o *ConfigPostgresSettings) MarshalJSON() ([]byte, error) { m := make(map[string]any) + if o.Jit != nil { + m["jit"] = o.Jit + } if o.MaxConnections != nil { m["maxConnections"] = o.MaxConnections } @@ -11764,6 +11769,13 @@ func (o *ConfigPostgresSettings) MarshalJSON() ([]byte, error) { return json.Marshal(m) } +func (o *ConfigPostgresSettings) GetJit() *string { + if o == nil { + o = &ConfigPostgresSettings{} + } + return o.Jit +} + func (o *ConfigPostgresSettings) GetMaxConnections() *int32 { if o == nil { o = &ConfigPostgresSettings{} @@ -11884,6 +11896,8 @@ func (o *ConfigPostgresSettings) GetMaxParallelMaintenanceWorkers() *int32 { } type ConfigPostgresSettingsUpdateInput struct { + Jit *string `json:"jit,omitempty" toml:"jit,omitempty"` + IsSetJit bool `json:"-"` MaxConnections *int32 `json:"maxConnections,omitempty" toml:"maxConnections,omitempty"` IsSetMaxConnections bool `json:"-"` SharedBuffers *string `json:"sharedBuffers,omitempty" toml:"sharedBuffers,omitempty"` @@ -11925,6 +11939,23 @@ func (o *ConfigPostgresSettingsUpdateInput) UnmarshalGQL(v interface{}) error { if !ok { return fmt.Errorf("must be map[string]interface{}, got %T", v) } + if v, ok := m["jit"]; ok { + if v == nil { + o.Jit = nil + } else { + // clearly a not very efficient shortcut + b, err := json.Marshal(v) + if err != nil { + return err + } + var x string + if err := json.Unmarshal(b, &x); err != nil { + return err + } + o.Jit = &x + } + o.IsSetJit = true + } if v, ok := m["maxConnections"]; ok { if v == nil { o.MaxConnections = nil @@ -12225,6 +12256,13 @@ func (o *ConfigPostgresSettingsUpdateInput) MarshalGQL(w io.Writer) { } } +func (o *ConfigPostgresSettingsUpdateInput) GetJit() *string { + if o == nil { + o = &ConfigPostgresSettingsUpdateInput{} + } + return o.Jit +} + func (o *ConfigPostgresSettingsUpdateInput) GetMaxConnections() *int32 { if o == nil { o = &ConfigPostgresSettingsUpdateInput{} @@ -12348,6 +12386,9 @@ func (s *ConfigPostgresSettings) Update(v *ConfigPostgresSettingsUpdateInput) { if v == nil { return } + if v.IsSetJit || v.Jit != nil { + s.Jit = v.Jit + } if v.IsSetMaxConnections || v.MaxConnections != nil { s.MaxConnections = v.MaxConnections } @@ -12402,6 +12443,7 @@ func (s *ConfigPostgresSettings) Update(v *ConfigPostgresSettingsUpdateInput) { } type ConfigPostgresSettingsInsertInput struct { + Jit *string `json:"jit,omitempty" toml:"jit,omitempty"` MaxConnections *int32 `json:"maxConnections,omitempty" toml:"maxConnections,omitempty"` SharedBuffers *string `json:"sharedBuffers,omitempty" toml:"sharedBuffers,omitempty"` EffectiveCacheSize *string `json:"effectiveCacheSize,omitempty" toml:"effectiveCacheSize,omitempty"` @@ -12421,6 +12463,13 @@ type ConfigPostgresSettingsInsertInput struct { MaxParallelMaintenanceWorkers *int32 `json:"maxParallelMaintenanceWorkers,omitempty" toml:"maxParallelMaintenanceWorkers,omitempty"` } +func (o *ConfigPostgresSettingsInsertInput) GetJit() *string { + if o == nil { + o = &ConfigPostgresSettingsInsertInput{} + } + return o.Jit +} + func (o *ConfigPostgresSettingsInsertInput) GetMaxConnections() *int32 { if o == nil { o = &ConfigPostgresSettingsInsertInput{} @@ -12541,6 +12590,7 @@ func (o *ConfigPostgresSettingsInsertInput) GetMaxParallelMaintenanceWorkers() * } func (s *ConfigPostgresSettings) Insert(v *ConfigPostgresSettingsInsertInput) { + s.Jit = v.Jit s.MaxConnections = v.MaxConnections s.SharedBuffers = v.SharedBuffers s.EffectiveCacheSize = v.EffectiveCacheSize @@ -12566,6 +12616,7 @@ func (s *ConfigPostgresSettings) Clone() *ConfigPostgresSettings { } v := &ConfigPostgresSettings{} + v.Jit = s.Jit v.MaxConnections = s.MaxConnections v.SharedBuffers = s.SharedBuffers v.EffectiveCacheSize = s.EffectiveCacheSize @@ -12590,6 +12641,7 @@ type ConfigPostgresSettingsComparisonExp struct { And []*ConfigPostgresSettingsComparisonExp `json:"_and,omitempty"` Not *ConfigPostgresSettingsComparisonExp `json:"_not,omitempty"` Or []*ConfigPostgresSettingsComparisonExp `json:"_or,omitempty"` + Jit *ConfigStringComparisonExp `json:"jit,omitempty"` MaxConnections *ConfigInt32ComparisonExp `json:"maxConnections,omitempty"` SharedBuffers *ConfigStringComparisonExp `json:"sharedBuffers,omitempty"` EffectiveCacheSize *ConfigStringComparisonExp `json:"effectiveCacheSize,omitempty"` @@ -12617,6 +12669,9 @@ func (exp *ConfigPostgresSettingsComparisonExp) Matches(o *ConfigPostgresSetting if o == nil { o = &ConfigPostgresSettings{} } + if o.Jit != nil && !exp.Jit.Matches(*o.Jit) { + return false + } if o.MaxConnections != nil && !exp.MaxConnections.Matches(*o.MaxConnections) { return false } diff --git a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/config.go b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/config.go index ba323b99f..a23275344 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/config.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/config.go @@ -19,7 +19,11 @@ func SecretsResolver[T any]( ) (*T, error) { vars := map[string]any{} for _, e := range secrets { - vars["secrets."+e.Name] = strings.ReplaceAll(e.Value, `"`, `\"`) + vars["secrets."+e.Name] = strings.ReplaceAll( + strings.ReplaceAll(e.Value, `"`, `\"`), + "\n", + "\\n", + ) } data, err := json.Marshal(conf) diff --git a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/postgres.go b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/postgres.go index 2205be05c..880350809 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/postgres.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/postgres.go @@ -38,6 +38,10 @@ func PostgresEnv( //nolint:funlen if config.GetPostgres().GetSettings() != nil { env = append(env, []EnvVar{ + { + Name: "JIT", + Value: Stringify(*config.GetPostgres().GetSettings().GetJit()), + }, { Name: "MAX_CONNECTIONS", Value: Stringify(*config.GetPostgres().GetSettings().GetMaxConnections()), diff --git a/vendor/github.com/nhost/be/services/mimir/schema/schema.cue b/vendor/github.com/nhost/be/services/mimir/schema/schema.cue index dc451729a..5399f97d5 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/schema.cue +++ b/vendor/github.com/nhost/be/services/mimir/schema/schema.cue @@ -170,7 +170,7 @@ import ( // Configuration for functions service #Functions: { node: { - version: 16|*18 + version: 18 } } @@ -186,6 +186,7 @@ import ( } settings?: { + jit: "off" | "on" | *"on" maxConnections: int32 | *100 sharedBuffers: string | *"128MB" effectiveCacheSize: string | *"4GB" diff --git a/vendor/github.com/nhost/be/services/mimir/schema/schema_gen.graphqls b/vendor/github.com/nhost/be/services/mimir/schema/schema_gen.graphqls index 37465f6f0..70b7faa9d 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/schema_gen.graphqls +++ b/vendor/github.com/nhost/be/services/mimir/schema/schema_gen.graphqls @@ -1860,6 +1860,10 @@ input ConfigPostgresComparisonExp { type ConfigPostgresSettings { """ + """ + jit: String + """ + """ maxConnections: ConfigInt32 """ @@ -1929,6 +1933,7 @@ type ConfigPostgresSettings { } input ConfigPostgresSettingsUpdateInput { + jit: String maxConnections: ConfigInt32 sharedBuffers: String effectiveCacheSize: String @@ -1949,6 +1954,7 @@ input ConfigPostgresSettingsUpdateInput { } input ConfigPostgresSettingsInsertInput { + jit: String maxConnections: ConfigInt32 sharedBuffers: String effectiveCacheSize: String @@ -1972,6 +1978,7 @@ input ConfigPostgresSettingsComparisonExp { _and: [ConfigPostgresSettingsComparisonExp!] _not: ConfigPostgresSettingsComparisonExp _or: [ConfigPostgresSettingsComparisonExp!] + jit: ConfigStringComparisonExp maxConnections: ConfigInt32ComparisonExp sharedBuffers: ConfigStringComparisonExp effectiveCacheSize: ConfigStringComparisonExp diff --git a/vendor/modules.txt b/vendor/modules.txt index 03337a107..d7ab56b32 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -399,7 +399,7 @@ github.com/muesli/reflow/wrap # github.com/muesli/termenv v0.15.2 ## explicit; go 1.17 github.com/muesli/termenv -# github.com/nhost/be v0.0.0-20230927103250-70010e0e7eac +# github.com/nhost/be v0.0.0-20231001065154-f72edc119cf0 ## explicit; go 1.21 github.com/nhost/be/services/mimir/model github.com/nhost/be/services/mimir/schema