From f43ff4404c1c2f95d218fafff729820ddb5cdfce Mon Sep 17 00:00:00 2001 From: David Barroso Date: Tue, 29 Jul 2025 10:59:03 +0200 Subject: [PATCH 1/2] chore: update versions --- .golangci.bck.yaml | 25 ++ .golangci.yaml | 67 +-- clienv/clienv.go | 4 + clienv/style.go | 8 +- clienv/table.go | 2 + clienv/wf_app_info.go | 4 +- clienv/wf_link.go | 18 +- clienv/wf_login.go | 43 +- clienv/wf_session.go | 1 + cmd/config/apply.go | 5 +- cmd/config/default.go | 3 + cmd/config/edit.go | 1 + cmd/config/example.go | 9 +- cmd/config/pull.go | 13 +- cmd/config/show.go | 1 + cmd/config/validate.go | 8 + cmd/config/validate_test.go | 1 + cmd/configserver/configserver.go | 4 + cmd/configserver/local.go | 3 +- cmd/configserver/local_test.go | 1 + cmd/configserver/logger.go | 2 + cmd/deployments/list.go | 14 +- cmd/deployments/logs.go | 2 +- cmd/deployments/new.go | 3 +- cmd/dev/cloud.go | 17 +- cmd/dev/compose.go | 1 + cmd/dev/hasura.go | 1 + cmd/dev/up.go | 25 +- cmd/dockercredentials/configure.go | 7 + cmd/dockercredentials/get.go | 3 + cmd/project/init.go | 12 +- cmd/project/link.go | 1 + cmd/project/list.go | 1 + cmd/run/config_deploy.go | 1 + cmd/run/config_edit.go | 1 + cmd/run/config_pull.go | 1 + cmd/run/config_show.go | 1 + cmd/run/config_validate.go | 17 +- cmd/secrets/create.go | 4 +- cmd/secrets/delete.go | 4 +- cmd/secrets/list.go | 1 + cmd/secrets/update.go | 4 +- cmd/software/uninstall.go | 2 + cmd/software/upgrade.go | 7 +- cmd/software/version.go | 12 +- cmd/user/login.go | 1 + dockercompose/auth.go | 1 + dockercompose/auth_test.go | 1 + dockercompose/compose.go | 6 + dockercompose/configserver.go | 2 + dockercompose/docker.go | 2 + dockercompose/dockercompose.go | 7 + dockercompose/graphql.go | 4 +- dockercompose/ingress.go | 2 + dockercompose/postgres.go | 1 + dockercompose/postgres_test.go | 1 + dockercompose/run.go | 1 + dockercompose/storage.go | 1 + dockercompose/url.go | 1 + .../databases/default/tables/auth_users.yaml | 7 + .../down.sql | 4 + .../up.sql | 2 + .../down.sql | 1 + .../up.sql | 5 + examples/myproject/nhost/nhost.toml | 11 +- flake.lock | 18 +- go.mod | 22 +- go.sum | 50 ++- main.go | 1 + nhostclient/auth.go | 7 +- nhostclient/nhostclient.go | 3 +- nhostclient/request.go | 3 + nhostclient/request_test.go | 3 + nhostclient/retryer.go | 2 + nhostclient/retryer_test.go | 1 + project/env/marshal.go | 2 + project/env/marshal_test.go | 1 + software/github.go | 4 +- software/sofware.go | 11 +- ssl/.ssl/local-fullchain.pem | 34 +- ssl/.ssl/local-privkey.pem | 6 +- ssl/.ssl/sub-fullchain.pem | 72 ++-- ssl/.ssl/sub-privkey.pem | 6 +- .../gqlgen/graphql/executable_schema.go | 47 ++- .../gqlgen/graphql/executor/executor.go | 19 +- .../99designs/gqlgen/graphql/fieldset.go | 5 + .../graphql/handler/transport/headers.go | 12 +- .../graphql/handler/transport/http_get.go | 5 +- .../graphql/handler/transport/http_post.go | 6 +- .../99designs/gqlgen/graphql/version.go | 2 +- .../go-viper/mapstructure/v2/.editorconfig | 3 + .../go-viper/mapstructure/v2/.golangci.yaml | 46 ++- .../go-viper/mapstructure/v2/README.md | 9 +- .../go-viper/mapstructure/v2/decode_hooks.go | 26 +- .../go-viper/mapstructure/v2/errors.go | 74 ++++ .../go-viper/mapstructure/v2/flake.lock | 390 +++++------------- .../go-viper/mapstructure/v2/flake.nix | 45 +- .../go-viper/mapstructure/v2/mapstructure.go | 220 +++++++--- .../github.com/nhost/be/lib/graphql/VERSION | 1 - .../nhost/be/lib/graphql/context/gin.go | 6 +- .../nhost/be/lib/graphql/context/logger.go | 1 + .../nhost/be/lib/graphql/handler/handler.go | 1 + .../be/lib/graphql/middleware/accounting.go | 1 + .../nhost/be/lib/graphql/middleware/logger.go | 1 + .../be/lib/graphql/middleware/prometheus.go | 8 +- .../graphql/middleware/session_variables.go | 5 + .../nhost/be/lib/graphql/project.nix | 3 +- .../nhost/be/services/mimir/graph/data.go | 6 + .../mimir/graph/generated/generated.go | 224 +++++++++- .../mimir/graph/m_change_database_version.go | 3 + .../services/mimir/graph/m_delete_config.go | 1 + .../graph/m_delete_run_service_config.go | 4 + .../services/mimir/graph/m_delete_secret.go | 1 + .../services/mimir/graph/m_insert_config.go | 2 + .../graph/m_insert_run_service_config.go | 3 + .../mimir/graph/m_replace_config_raw_json.go | 2 + .../graph/m_replace_run_service_config.go | 3 + .../graph/m_update_run_service_config.go | 2 + .../be/services/mimir/graph/q_app_secrets.go | 1 + .../be/services/mimir/graph/q_apps_secrets.go | 1 + .../nhost/be/services/mimir/graph/q_config.go | 1 + .../services/mimir/graph/q_config_raw_json.go | 7 +- .../be/services/mimir/graph/q_configs.go | 3 + .../mimir/graph/q_run_service_config.go | 3 + .../graph/q_run_service_config_raw_json.go | 1 + .../mimir/graph/q_run_service_configs.go | 3 + .../services/mimir/graph/q_system_config.go | 1 + .../services/mimir/graph/q_system_configs.go | 2 + .../nhost/be/services/mimir/graph/resolver.go | 3 + .../nhost/be/services/mimir/graph/router.go | 3 + .../services/mimir/graph/schema.resolvers.go | 2 +- .../be/services/mimir/model/cuegraph_gen.go | 132 +++++- .../nhost/be/services/mimir/model/secrets.go | 1 + .../be/services/mimir/schema/appconfig/ai.go | 1 + .../services/mimir/schema/appconfig/common.go | 8 + .../services/mimir/schema/appconfig/config.go | 4 + .../services/mimir/schema/appconfig/hasura.go | 1 + .../mimir/schema/appconfig/hasura_auth.go | 26 +- .../mimir/schema/appconfig/postgres.go | 8 + .../mimir/schema/appconfig/versions.go | 3 + .../nhost/be/services/mimir/schema/schema.cue | 8 +- .../nhost/be/services/mimir/schema/schema.go | 4 + .../services/mimir/schema/schema_gen.graphqls | 14 + .../nhost/be/tools/cuegraph/types/int16.go | 4 +- .../nhost/be/tools/cuegraph/types/int8.go | 4 +- .../nhost/be/tools/cuegraph/types/uint16.go | 4 +- .../nhost/be/tools/cuegraph/types/uint8.go | 6 +- .../vektah/gqlparser/v2/gqlerror/error.go | 9 + .../vektah/gqlparser/v2/gqlparser.go | 31 +- .../vektah/gqlparser/v2/parser/parser.go | 3 +- .../gqlparser/v2/validator/core/core.go | 24 ++ .../gqlparser/v2/validator/core/helpers.go | 154 +++++++ .../gqlparser/v2/validator/{ => core}/walk.go | 2 +- .../vektah/gqlparser/v2/validator/error.go | 55 --- .../gqlparser/v2/validator/messaging.go | 39 -- .../validator/rules/fields_on_correct_type.go | 6 +- .../rules/fragments_on_composite_types.go | 6 +- .../validator/rules/known_argument_names.go | 6 +- .../v2/validator/rules/known_directives.go | 6 +- .../validator/rules/known_fragment_names.go | 6 +- .../v2/validator/rules/known_root_type.go | 6 +- .../v2/validator/rules/known_type_names.go | 6 +- .../rules/lone_anonymous_operation.go | 6 +- .../rules/max_introspection_depth.go | 6 +- .../v2/validator/rules/no_fragment_cycles.go | 6 +- .../validator/rules/no_undefined_variables.go | 6 +- .../v2/validator/rules/no_unused_fragments.go | 6 +- .../v2/validator/rules/no_unused_variables.go | 6 +- .../rules/overlapping_fields_can_be_merged.go | 6 +- .../rules/possible_fragment_spreads.go | 6 +- .../rules/provided_required_arguments.go | 6 +- .../gqlparser/v2/validator/rules/rules.go | 119 ++++++ .../v2/validator/rules/scalar_leafs.go | 6 +- .../rules/single_field_subscriptions.go | 6 +- .../validator/rules/unique_argument_names.go | 6 +- .../rules/unique_directives_per_location.go | 6 +- .../validator/rules/unique_fragment_names.go | 6 +- .../rules/unique_input_field_names.go | 6 +- .../validator/rules/unique_operation_names.go | 6 +- .../validator/rules/unique_variable_names.go | 6 +- .../validator/rules/values_of_correct_type.go | 6 +- .../rules/variables_are_input_types.go | 6 +- .../rules/variables_in_allowed_position.go | 6 +- .../gqlparser/v2/validator/suggestionList.go | 69 ---- .../gqlparser/v2/validator/validator.go | 77 +++- .../golang.org/x/crypto/ssh/agent/client.go | 22 +- .../golang.org/x/crypto/ssh/agent/server.go | 4 +- vendor/golang.org/x/crypto/ssh/certs.go | 41 +- vendor/golang.org/x/crypto/ssh/cipher.go | 40 +- vendor/golang.org/x/crypto/ssh/client.go | 1 + vendor/golang.org/x/crypto/ssh/common.go | 375 ++++++++++++----- vendor/golang.org/x/crypto/ssh/connection.go | 12 + vendor/golang.org/x/crypto/ssh/handshake.go | 24 +- vendor/golang.org/x/crypto/ssh/kex.go | 107 ++--- vendor/golang.org/x/crypto/ssh/keys.go | 25 +- vendor/golang.org/x/crypto/ssh/mac.go | 12 +- vendor/golang.org/x/crypto/ssh/messages.go | 6 +- vendor/golang.org/x/crypto/ssh/mlkem.go | 10 +- vendor/golang.org/x/crypto/ssh/server.go | 12 +- vendor/golang.org/x/crypto/ssh/transport.go | 15 +- vendor/golang.org/x/mod/semver/semver.go | 30 +- vendor/golang.org/x/net/http2/frame.go | 16 +- vendor/golang.org/x/net/trace/events.go | 2 +- vendor/modules.txt | 25 +- 204 files changed, 2395 insertions(+), 1246 deletions(-) create mode 100644 .golangci.bck.yaml create mode 100644 examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/down.sql create mode 100644 examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/up.sql create mode 100644 examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/down.sql create mode 100644 examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/up.sql create mode 100644 vendor/github.com/go-viper/mapstructure/v2/errors.go delete mode 100644 vendor/github.com/nhost/be/lib/graphql/VERSION create mode 100644 vendor/github.com/vektah/gqlparser/v2/validator/core/core.go create mode 100644 vendor/github.com/vektah/gqlparser/v2/validator/core/helpers.go rename vendor/github.com/vektah/gqlparser/v2/validator/{ => core}/walk.go (99%) delete mode 100644 vendor/github.com/vektah/gqlparser/v2/validator/error.go delete mode 100644 vendor/github.com/vektah/gqlparser/v2/validator/messaging.go create mode 100644 vendor/github.com/vektah/gqlparser/v2/validator/rules/rules.go delete mode 100644 vendor/github.com/vektah/gqlparser/v2/validator/suggestionList.go diff --git a/.golangci.bck.yaml b/.golangci.bck.yaml new file mode 100644 index 000000000..73cb8fac0 --- /dev/null +++ b/.golangci.bck.yaml @@ -0,0 +1,25 @@ +--- +linters: + enable-all: true + disable: + - varnamelen + - gomoddirectives + - nlreturn + - wsl + - depguard + - tenv # deprecated + +issues: + exclude-rules: + - path: _test\.go + linters: + - funlen + - ireturn + + - linters: + - lll + source: "^//go:generate " + + - linters: + - gochecknoglobals + text: "Version is a global variable" diff --git a/.golangci.yaml b/.golangci.yaml index 73cb8fac0..42aa6225e 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,25 +1,44 @@ ---- +version: "2" linters: - enable-all: true - disable: - - varnamelen - - gomoddirectives - - nlreturn - - wsl - - depguard - - tenv # deprecated - -issues: - exclude-rules: - - path: _test\.go - linters: - - funlen - - ireturn - - - linters: - - lll - source: "^//go:generate " - - - linters: - - gochecknoglobals - text: "Version is a global variable" + default: all + disable: + - depguard + - gomoddirectives + - nlreturn + - varnamelen + - wsl + - noinlineerr + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - funlen + - ireturn + path: _test\.go + - linters: + - lll + source: '^//go:generate ' + - linters: + - gochecknoglobals + text: Version is a global variable + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofmt + - gofumpt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/clienv/clienv.go b/clienv/clienv.go index a7b948e1b..4b3ed5569 100644 --- a/clienv/clienv.go +++ b/clienv/clienv.go @@ -60,6 +60,7 @@ func FromCLI(cCtx *cli.Context) *CliEnv { if err != nil { panic(err) } + return &CliEnv{ stdout: cCtx.App.Writer, stderr: cCtx.App.ErrWriter, @@ -105,12 +106,14 @@ func (ce *CliEnv) GetNhostClient(ctx context.Context) (*nhostclient.Client, erro if err != nil { return nil, fmt.Errorf("failed to load session: %w", err) } + ce.nhclient = nhostclient.New( ce.authURL, ce.graphqlURL, graphql.WithAccessToken(session.Session.AccessToken), ) } + return ce.nhclient, nil } @@ -118,5 +121,6 @@ func (ce *CliEnv) GetNhostPublicClient() (*nhostclient.Client, error) { if ce.nhpublicclient == nil { ce.nhpublicclient = nhostclient.New(ce.authURL, ce.graphqlURL) } + return ce.nhpublicclient, nil } diff --git a/clienv/style.go b/clienv/style.go index 808ee1099..f8751118f 100644 --- a/clienv/style.go +++ b/clienv/style.go @@ -67,8 +67,11 @@ func (ce *CliEnv) PromptMessage(msg string, a ...any) { func (ce *CliEnv) PromptInput(hide bool) (string, error) { reader := bufio.NewReader(os.Stdin) - var response string - var err error + + var ( + response string + err error + ) if !hide { response, err = reader.ReadString('\n') @@ -80,6 +83,7 @@ func (ce *CliEnv) PromptInput(hide bool) (string, error) { if err != nil { return "", fmt.Errorf("failed to read input: %w", err) } + response = string(output) } diff --git a/clienv/table.go b/clienv/table.go index f3e88e8b3..3a5b1a47c 100644 --- a/clienv/table.go +++ b/clienv/table.go @@ -23,10 +23,12 @@ func Table(columns ...Column) string { strs := make([]string, len(columns)) for i, col := range columns { c := make([]string, len(col.Rows)+1) + c[0] = listHeader(col.Header) for i, row := range col.Rows { c[i+1] = listItem(row) } + strs[i] = list.Render( lipgloss.JoinVertical( lipgloss.Left, diff --git a/clienv/wf_app_info.go b/clienv/wf_app_info.go index 80db7a852..941559b7c 100644 --- a/clienv/wf_app_info.go +++ b/clienv/wf_app_info.go @@ -19,6 +19,7 @@ func getRemoteAppInfo( if err != nil { return nil, fmt.Errorf("failed to get nhost client: %w", err) } + resp, err := cl.GetOrganizationsAndWorkspacesApps( ctx, ) @@ -42,7 +43,7 @@ func getRemoteAppInfo( } } - return nil, fmt.Errorf("failed to find app with subdomain: %s", subdomain) //nolint:goerr113 + return nil, fmt.Errorf("failed to find app with subdomain: %s", subdomain) //nolint:err113 } func (ce *CliEnv) GetAppInfo( @@ -63,6 +64,7 @@ func (ce *CliEnv) GetAppInfo( } else { ce.Warnln("Failed to find linked project: %v", err) ce.Infoln("Please run `nhost link` to link a project first") + return nil, err } } diff --git a/clienv/wf_link.go b/clienv/wf_link.go index bd8dc932f..e0cb887f2 100644 --- a/clienv/wf_link.go +++ b/clienv/wf_link.go @@ -13,7 +13,7 @@ import ( func Printlist(ce *CliEnv, orgs *graphql.GetOrganizationsAndWorkspacesApps) error { if len(orgs.GetWorkspaces())+len(orgs.GetOrganizations()) == 0 { - return errors.New("no apps found") //nolint:goerr113 + return errors.New("no apps found") //nolint:err113 } num := Column{ @@ -65,13 +65,14 @@ func Printlist(ce *CliEnv, orgs *graphql.GetOrganizationsAndWorkspacesApps) erro func confirmApp(ce *CliEnv, app *graphql.AppSummaryFragment) error { ce.PromptMessage("Enter project subdomain to confirm: ") + confirm, err := ce.PromptInput(false) if err != nil { return fmt.Errorf("failed to read input: %w", err) } if confirm != app.Subdomain { - return errors.New("input doesn't match the subdomain") //nolint:goerr113 + return errors.New("input doesn't match the subdomain") //nolint:err113 } return nil @@ -82,15 +83,20 @@ func getApp( idx string, ) (*graphql.AppSummaryFragment, error) { x := 1 + var app *graphql.AppSummaryFragment + OUTER: + for _, orgs := range orgs.GetOrganizations() { for _, a := range orgs.GetApps() { if strconv.Itoa(x) == idx { a := a app = a + break OUTER } + x++ } } @@ -105,14 +111,16 @@ OUTER2: if strconv.Itoa(x) == idx { a := a app = a + break OUTER2 } + x++ } } if app == nil { - return nil, errors.New("invalid input") //nolint:goerr113 + return nil, errors.New("invalid input") //nolint:err113 } return app, nil @@ -123,13 +131,14 @@ func (ce *CliEnv) Link(ctx context.Context) (*graphql.AppSummaryFragment, error) if err != nil { return nil, fmt.Errorf("failed to get nhost client: %w", err) } + orgs, err := cl.GetOrganizationsAndWorkspacesApps(ctx) if err != nil { return nil, fmt.Errorf("failed to get workspaces: %w", err) } if len(orgs.GetWorkspaces())+len(orgs.GetOrganizations()) == 0 { - return nil, errors.New("no apps found") //nolint:goerr113 + return nil, errors.New("no apps found") //nolint:err113 } if err := Printlist(ce, orgs); err != nil { @@ -137,6 +146,7 @@ func (ce *CliEnv) Link(ctx context.Context) (*graphql.AppSummaryFragment, error) } ce.PromptMessage("Select the workspace # to link: ") + idx, err := ce.PromptInput(false) if err != nil { return nil, fmt.Errorf("failed to read workspace: %w", err) diff --git a/clienv/wf_login.go b/clienv/wf_login.go index 5ace7d04d..56b4e5136 100644 --- a/clienv/wf_login.go +++ b/clienv/wf_login.go @@ -43,13 +43,16 @@ func savePAT( func signinHandler(ch chan<- string) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { ch <- r.URL.Query().Get("refreshToken") + fmt.Fprintf(w, "You may now close this window.") } } -func openBrowser(url string) error { - var cmd string - var args []string +func openBrowser(ctx context.Context, url string) error { + var ( + cmd string + args []string + ) switch runtime.GOOS { case "darwin": @@ -57,8 +60,9 @@ func openBrowser(url string) error { default: // "linux", "freebsd", "openbsd", "netbsd" cmd = "xdg-open" } + args = append(args, url) - if err := exec.Command(cmd, args...).Start(); err != nil { + if err := exec.CommandContext(ctx, cmd, args...).Start(); err != nil { return fmt.Errorf("failed to open browser: %w", err) } @@ -76,12 +80,13 @@ func getTLSServer() (*http.Server, error) { // Type assert the private key to crypto.PrivateKey pk, ok := privateKey.(crypto.PrivateKey) if !ok { - return nil, errors.New( //nolint:goerr113 + return nil, errors.New( //nolint:err113 "failed to type assert private key to crypto.PrivateKey", ) } block, _ = pem.Decode(ssl.LocalCertFile) + certificate, err := x509.ParseCertificate(block.Bytes) if err != nil { return nil, fmt.Errorf("failed to parse certificate: %w", err) @@ -110,6 +115,7 @@ func (ce *CliEnv) loginPAT(pat string) credentials.Credentials { ID: "", PersonalAccessToken: pat, } + return session } @@ -119,9 +125,12 @@ func (ce *CliEnv) loginEmailPassword( password string, ) (credentials.Credentials, error) { cl := nhostclient.New(ce.AuthURL(), ce.GraphqlURL()) + var err error + if email == "" { ce.PromptMessage("email: ") + email, err = ce.PromptInput(false) if err != nil { return credentials.Credentials{}, fmt.Errorf("failed to read email: %w", err) @@ -132,12 +141,14 @@ func (ce *CliEnv) loginEmailPassword( ce.PromptMessage("password: ") password, err = ce.PromptInput(true) ce.Println("") + if err != nil { return credentials.Credentials{}, fmt.Errorf("failed to read password: %w", err) } } ce.Infoln("Authenticating") + loginResp, err := cl.Login(ctx, email, password) if err != nil { return credentials.Credentials{}, fmt.Errorf("failed to login: %w", err) @@ -147,6 +158,7 @@ func (ce *CliEnv) loginEmailPassword( if err != nil { return credentials.Credentials{}, fmt.Errorf("failed to create PAT: %w", err) } + ce.Infoln("Successfully logged in") return session, nil @@ -155,6 +167,7 @@ func (ce *CliEnv) loginEmailPassword( func (ce *CliEnv) loginGithub(ctx context.Context) (credentials.Credentials, error) { refreshToken := make(chan string) http.HandleFunc("/signin", signinHandler(refreshToken)) + go func() { server, err := getTLSServer() if err != nil { @@ -168,22 +181,27 @@ func (ce *CliEnv) loginGithub(ctx context.Context) (credentials.Credentials, err signinPage := ce.AuthURL() + "/signin/provider/github/?redirectTo=https://local.dashboard.local.nhost.run:8099/signin" ce.Infoln("Opening browser to sign-in") - if err := openBrowser(signinPage); err != nil { + + if err := openBrowser(ctx, signinPage); err != nil { return credentials.Credentials{}, err } + ce.Infoln("Waiting for sign-in to complete") refreshTokenValue := <-refreshToken cl := nhostclient.New(ce.AuthURL(), ce.GraphqlURL()) + refreshTokenResp, err := cl.RefreshToken(ctx, refreshTokenValue) if err != nil { return credentials.Credentials{}, fmt.Errorf("failed to get access token: %w", err) } + session, err := cl.CreatePAT(ctx, refreshTokenResp.AccessToken) if err != nil { return credentials.Credentials{}, fmt.Errorf("failed to create PAT: %w", err) } + ce.Infoln("Successfully logged in") return session, nil @@ -192,6 +210,7 @@ func (ce *CliEnv) loginGithub(ctx context.Context) (credentials.Credentials, err func (ce *CliEnv) loginMethod(ctx context.Context) (credentials.Credentials, error) { ce.Infoln("Select authentication method:\n1. PAT\n2. Email/Password\n3. Github") ce.PromptMessage("method: ") + method, err := ce.PromptInput(false) if err != nil { return credentials.Credentials{}, fmt.Errorf( @@ -201,13 +220,16 @@ func (ce *CliEnv) loginMethod(ctx context.Context) (credentials.Credentials, err } var session credentials.Credentials + switch method { case "1": ce.PromptMessage("PAT: ") + pat, err := ce.PromptInput(true) if err != nil { return credentials.Credentials{}, fmt.Errorf("failed to read PAT: %w", err) } + session = ce.loginPAT(pat) case "2": session, err = ce.loginEmailPassword(ctx, "", "") @@ -216,6 +238,7 @@ func (ce *CliEnv) loginMethod(ctx context.Context) (credentials.Credentials, err default: return ce.loginMethod(ctx) } + return session, err } @@ -232,6 +255,7 @@ func (ce *CliEnv) verifyEmail( ce.Infoln("A verification email has been sent to %s", email) ce.Infoln("Please verify your email address and try again") + return nil } @@ -241,8 +265,11 @@ func (ce *CliEnv) Login( email string, password string, ) (credentials.Credentials, error) { - var session credentials.Credentials - var err error + var ( + session credentials.Credentials + err error + ) + switch { case pat != "": session = ce.loginPAT(pat) diff --git a/clienv/wf_session.go b/clienv/wf_session.go index fbe0839a9..42d0d3d1e 100644 --- a/clienv/wf_session.go +++ b/clienv/wf_session.go @@ -21,6 +21,7 @@ func (ce *CliEnv) LoadSession( } cl := nhostclient.New(ce.AuthURL(), ce.GraphqlURL()) + session, err := cl.LoginPAT(ctx, creds.PersonalAccessToken) if err != nil { return credentials.Session{}, fmt.Errorf("failed to login: %w", err) diff --git a/cmd/config/apply.go b/cmd/config/apply.go index 88dcf3dcb..3d06ad14d 100644 --- a/cmd/config/apply.go +++ b/cmd/config/apply.go @@ -42,6 +42,7 @@ func commandApply(cCtx *cli.Context) error { } ce.Infoln("Validating configuration...") + cfg, _, err := ValidateRemote( cCtx.Context, ce, @@ -66,12 +67,14 @@ func Apply( ce.PromptMessage( "We are going to overwrite the project's configuration. Do you want to proceed? [y/N] ", ) + resp, err := ce.PromptInput(false) if err != nil { return fmt.Errorf("failed to read input: %w", err) } + if resp != "y" && resp != "Y" { - return errors.New("aborting") //nolint:goerr113 + return errors.New("aborting") //nolint:err113 } } diff --git a/cmd/config/default.go b/cmd/config/default.go index 38cba23a1..c37cace3e 100644 --- a/cmd/config/default.go +++ b/cmd/config/default.go @@ -29,9 +29,11 @@ func commandDefault(cCtx *cli.Context) error { } ce.Infoln("Initializing Nhost project") + if err := InitConfigAndSecrets(ce); err != nil { return fmt.Errorf("failed to initialize project: %w", err) } + ce.Infoln("Successfully generated default configuration and secrets") return nil @@ -42,6 +44,7 @@ func InitConfigAndSecrets(ce *clienv.CliEnv) error { if err != nil { return fmt.Errorf("failed to create default config: %w", err) } + if err := clienv.MarshalFile(config, ce.Path.NhostToml(), toml.Marshal); err != nil { return fmt.Errorf("failed to save config: %w", err) } diff --git a/cmd/config/edit.go b/cmd/config/edit.go index 2fbf68282..c84ca6ce5 100644 --- a/cmd/config/edit.go +++ b/cmd/config/edit.go @@ -146,6 +146,7 @@ func edit(cCtx *cli.Context) error { if err := EditFile(cCtx.Context, cCtx.String(flagEditor), ce.Path.NhostToml()); err != nil { return fmt.Errorf("failed to edit config: %w", err) } + return nil } diff --git a/cmd/config/example.go b/cmd/config/example.go index da40ba2c9..63423f477 100644 --- a/cmd/config/example.go +++ b/cmd/config/example.go @@ -119,7 +119,7 @@ func commandExample(cCtx *cli.Context) error { //nolint:funlen,maintidx }, Functions: &model.ConfigFunctions{ Node: &model.ConfigFunctionsNode{ - Version: ptr(int(18)), + Version: ptr(int(22)), }, Resources: &model.ConfigFunctionsResources{ Networking: &model.ConfigNetworking{ @@ -209,8 +209,9 @@ func commandExample(cCtx *cli.Context) error { //nolint:funlen,maintidx ExpiresIn: ptr(uint32(3600)), CustomClaims: []*model.ConfigAuthsessionaccessTokenCustomClaims{ { - Key: "key", - Value: "value", + Key: "key", + Value: "value", + Default: ptr("default-value"), }, }, }, @@ -419,6 +420,7 @@ func commandExample(cCtx *cli.Context) error { //nolint:funlen,maintidx MaxWalSenders: ptr(int32(10)), MaxReplicationSlots: ptr(int32(10)), ArchiveTimeout: ptr(int32(300)), + TrackIoTiming: ptr("off"), }, Pitr: &model.ConfigPostgresPitr{ Retention: ptr(uint8(7)), @@ -535,6 +537,7 @@ func commandExample(cCtx *cli.Context) error { //nolint:funlen,maintidx if err != nil { return fmt.Errorf("failed to create schema: %w", err) } + if err := sch.ValidateConfig(cfg); err != nil { return fmt.Errorf("failed to validate config: %w", err) } diff --git a/cmd/config/pull.go b/cmd/config/pull.go index e8836f210..a71aa6a83 100644 --- a/cmd/config/pull.go +++ b/cmd/config/pull.go @@ -59,6 +59,7 @@ func commandPull(cCtx *cli.Context) error { } writeSecrets := true + if !skipConfirmation { if err := verifyFile(ce, ce.Path.Secrets()); err != nil { writeSecrets = false @@ -71,6 +72,7 @@ func commandPull(cCtx *cli.Context) error { } _, err = Pull(cCtx.Context, ce, proj, writeSecrets) + return err } @@ -79,14 +81,17 @@ func verifyFile(ce *clienv.CliEnv, name string) error { ce.PromptMessage("%s", name+" already exists. Do you want to overwrite it? [y/N] ", ) + resp, err := ce.PromptInput(false) if err != nil { return fmt.Errorf("failed to read input: %w", err) } + if resp != "y" && resp != "Y" { - return errors.New("aborting") //nolint:goerr113 + return errors.New("aborting") //nolint:err113 } } + return nil } @@ -105,11 +110,13 @@ func respToSecrets(env []*graphql.GetSecrets_AppSecrets, anonymize bool) model.S s.Value = "FIXME" } } + secrets[i] = &model.ConfigEnvironmentVariable{ Name: s.Name, Value: s.Value, } } + return secrets } @@ -119,10 +126,12 @@ func pullSecrets( proj *graphql.AppSummaryFragment, ) error { ce.Infoln("Getting secrets list from Nhost...") + cl, err := ce.GetNhostClient(ctx) if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + resp, err := cl.GetSecrets( ctx, proj.ID, @@ -137,6 +146,7 @@ func pullSecrets( } ce.Infoln("Adding .secrets to .gitignore...") + if err := system.AddToGitignore("\n.secrets\n"); err != nil { return fmt.Errorf("failed to add .secrets to .gitignore: %w", err) } @@ -156,6 +166,7 @@ func Pull( if err != nil { return nil, fmt.Errorf("failed to get nhost client: %w", err) } + cfg, err := cl.GetConfigRawJSON( ctx, proj.ID, diff --git a/cmd/config/show.go b/cmd/config/show.go index 97547cdb8..637aaa074 100644 --- a/cmd/config/show.go +++ b/cmd/config/show.go @@ -49,5 +49,6 @@ func commandShow(c *cli.Context) error { } ce.Println("%s", b) + return nil } diff --git a/cmd/config/validate.go b/cmd/config/validate.go index d5a40d35f..3af5d6fff 100644 --- a/cmd/config/validate.go +++ b/cmd/config/validate.go @@ -49,6 +49,7 @@ func commandValidate(cCtx *cli.Context) error { proj.GetSubdomain(), proj.GetID(), ) + return err } @@ -61,10 +62,13 @@ func commandValidate(cCtx *cli.Context) error { } ce.Infoln("Verifying configuration...") + if _, err := Validate(ce, "local", secrets); err != nil { return err } + ce.Infoln("Configuration is valid!") + return nil } @@ -118,6 +122,7 @@ func Validate( if clienv.PathExists(ce.Path.Overlay(subdomain)) { var err error + cfg, err = ApplyJSONPatches(*cfg, ce.Path.Overlay(subdomain)) if err != nil { return nil, fmt.Errorf("failed to apply json patches: %w", err) @@ -155,6 +160,7 @@ func ValidateRemote( if clienv.PathExists(ce.Path.Overlay(subdomain)) { var err error + cfg, err = ApplyJSONPatches(*cfg, ce.Path.Overlay(subdomain)) if err != nil { return nil, nil, fmt.Errorf("failed to apply json patches: %w", err) @@ -167,10 +173,12 @@ func ValidateRemote( } ce.Infoln("Getting secrets...") + cl, err := ce.GetNhostClient(ctx) if err != nil { return nil, nil, fmt.Errorf("failed to get nhost client: %w", err) } + secretsResp, err := cl.GetSecrets( ctx, appID, diff --git a/cmd/config/validate_test.go b/cmd/config/validate_test.go index 805816d6c..b05b704a5 100644 --- a/cmd/config/validate_test.go +++ b/cmd/config/validate_test.go @@ -270,6 +270,7 @@ func TestValidate(t *testing.T) { err, ) } + cfg, err := config.Validate(ce, "local", secrets) if err != nil { t.Fatal(err) diff --git a/cmd/configserver/configserver.go b/cmd/configserver/configserver.go index d10e46dc6..d587c2ad1 100644 --- a/cmd/configserver/configserver.go +++ b/cmd/configserver/configserver.go @@ -94,6 +94,7 @@ func dummyMiddleware2( func runServicesFiles(runServices ...string) map[string]string { m := make(map[string]string) + for _, path := range runServices { id := uuid.NewString() m[id] = path @@ -112,10 +113,12 @@ func serve(cCtx *cli.Context) error { runServices := runServicesFiles(cCtx.StringSlice(storageLocalRunServicesPath)...) st := NewLocal(configFile, secretsFile, runServices) + data, err := st.GetApps(configFile, secretsFile, runServices) if err != nil { return fmt.Errorf("failed to get data from plugin: %w", err) } + plugins := []graph.Plugin{st} resolver, err := graph.NewResolver(data, Querier{}, plugins) @@ -137,5 +140,6 @@ func serve(cCtx *cli.Context) error { if err := r.Run(cCtx.String(bindFlag)); err != nil { return fmt.Errorf("failed to run gin: %w", err) } + return nil } diff --git a/cmd/configserver/local.go b/cmd/configserver/local.go index ee6c48a49..32a69acb8 100644 --- a/cmd/configserver/local.go +++ b/cmd/configserver/local.go @@ -113,6 +113,7 @@ func (l *Local) GetApps( if cfg.GetPostgres().GetVersion() != nil { pgMajorVersion = strings.Split(*cfg.GetPostgres().GetVersion(), ".")[0] } + return []*graph.App{ { Config: cfg, @@ -189,7 +190,7 @@ func (l *Local) UpdateRunServiceConfig( ) error { wr, ok := l.runServices[newSvc.ServiceID] if !ok { - return fmt.Errorf("run service not found: %s", newSvc.ServiceID) //nolint:goerr113 + return fmt.Errorf("run service not found: %s", newSvc.ServiceID) //nolint:err113 } b, err := toml.Marshal(newSvc.Config) diff --git a/cmd/configserver/local_test.go b/cmd/configserver/local_test.go index 86c808a80..2a5732df7 100644 --- a/cmd/configserver/local_test.go +++ b/cmd/configserver/local_test.go @@ -130,6 +130,7 @@ func TestLocalGetApps(t *testing.T) { secretsF.Name(), nil, ) + got, err := st.GetApps(configF.Name(), secretsF.Name(), nil) if err != nil { t.Errorf("GetApps() got error: %v", err) diff --git a/cmd/configserver/logger.go b/cmd/configserver/logger.go index a9dc0def9..a2e9e83dc 100644 --- a/cmd/configserver/logger.go +++ b/cmd/configserver/logger.go @@ -46,7 +46,9 @@ func logFlags(logger logrus.FieldLogger, cCtx *cli.Context) { fields[name] = "******" continue } + fields[name] = cCtx.Generic(name) } + logger.WithFields(fields).Info("started with settings") } diff --git a/cmd/deployments/list.go b/cmd/deployments/list.go index 6b44ea672..16df82eb9 100644 --- a/cmd/deployments/list.go +++ b/cmd/deployments/list.go @@ -24,32 +24,26 @@ func printDeployments(ce *clienv.CliEnv, deployments []*graphql.ListDeployments_ Header: "ID", Rows: make([]string, 0), } - date := clienv.Column{ Header: "Date", Rows: make([]string, 0), } - duration := clienv.Column{ Header: "Duration", Rows: make([]string, 0), } - status := clienv.Column{ Header: "Status", Rows: make([]string, 0), } - user := clienv.Column{ Header: "User", Rows: make([]string, 0), } - ref := clienv.Column{ Header: "Ref", Rows: make([]string, 0), } - message := clienv.Column{ Header: "Message", Rows: make([]string, 0), @@ -61,8 +55,11 @@ func printDeployments(ce *clienv.CliEnv, deployments []*graphql.ListDeployments_ startedAt = *d.DeploymentStartedAt } - var endedAt time.Time - var deplPuration time.Duration + var ( + endedAt time.Time + deplPuration time.Duration + ) + if d.DeploymentEndedAt != nil && !d.DeploymentEndedAt.IsZero() { endedAt = *d.DeploymentEndedAt deplPuration = endedAt.Sub(startedAt) @@ -92,6 +89,7 @@ func commandList(cCtx *cli.Context) error { if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + deployments, err := cl.ListDeployments( cCtx.Context, proj.ID, diff --git a/cmd/deployments/logs.go b/cmd/deployments/logs.go index 6ff3ec3f0..4e9327258 100644 --- a/cmd/deployments/logs.go +++ b/cmd/deployments/logs.go @@ -104,7 +104,7 @@ func showLogsFollow( func commandLogs(cCtx *cli.Context) error { deploymentID := cCtx.Args().First() if deploymentID == "" { - return errors.New("deployment_id is required") //nolint:goerr113 + return errors.New("deployment_id is required") //nolint:err113 } ce := clienv.FromCLI(cCtx) diff --git a/cmd/deployments/new.go b/cmd/deployments/new.go index dc75c3e2e..e90952aaa 100644 --- a/cmd/deployments/new.go +++ b/cmd/deployments/new.go @@ -100,6 +100,7 @@ func commandNew(cCtx *cli.Context) error { if cCtx.Bool(flagFollow) { ce.Println("") + ctx, cancel := context.WithTimeout(cCtx.Context, cCtx.Duration(flagTimeout)) defer cancel() @@ -109,7 +110,7 @@ func commandNew(cCtx *cli.Context) error { } if status != "DEPLOYED" { - return fmt.Errorf("deployment failed: %s", status) //nolint:goerr113 + return fmt.Errorf("deployment failed: %s", status) //nolint:err113 } } diff --git a/cmd/dev/cloud.go b/cmd/dev/cloud.go index 0183c7bf6..2f90b0e7f 100644 --- a/cmd/dev/cloud.go +++ b/cmd/dev/cloud.go @@ -94,12 +94,13 @@ func commandCloud(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) if !clienv.PathExists(ce.Path.NhostToml()) { - return errors.New( //nolint:goerr113 + return errors.New( //nolint:err113 "no nhost project found, please run `nhost init` or `nhost config pull`", ) } + if !clienv.PathExists(ce.Path.Secrets()) { - return errors.New( //nolint:goerr113 + return errors.New( //nolint:err113 "no secrets found, please run `nhost init` or `nhost config pull`", ) } @@ -115,6 +116,7 @@ func commandCloud(cCtx *cli.Context) error { } applySeeds := cCtx.Bool(flagApplySeeds) + return Cloud( cCtx.Context, ce, @@ -157,12 +159,14 @@ func cloud( //nolint:funlen sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) + go func() { <-sigChan cancel() }() ce.Infoln("Validating configuration...") + cfg, cfgSecrets, err := config.ValidateRemote( ctx, ce, @@ -175,12 +179,15 @@ func cloud( //nolint:funlen ctxWithTimeout, cancel := context.WithTimeout(ctx, 5*time.Second) //nolint:mnd defer cancel() + ce.Infoln("Checking versions...") + if err := software.CheckVersions(ctxWithTimeout, ce, cfgSecrets, appVersion); err != nil { ce.Warnln("Problem verifying recommended versions: %s", err.Error()) } ce.Infoln("Setting up Nhost development environment...") + composeFile, err := dockercompose.CloudComposeFileFromConfig( cfgSecrets, ce.LocalSubdomain(), @@ -202,16 +209,19 @@ func cloud( //nolint:funlen if err != nil { return fmt.Errorf("failed to generate docker-compose.yaml: %w", err) } + if err := dc.WriteComposeFile(composeFile); err != nil { return fmt.Errorf("failed to write docker-compose.yaml: %w", err) } ce.Infoln("Starting Nhost development environment...") + if err = dc.Start(ctx); err != nil { return fmt.Errorf("failed to start Nhost development environment: %w", err) } ce.Infoln("Applying configuration to Nhost Cloud project...") + if err = config.Apply(ctx, ce, proj.GetID(), cfg, true); err != nil { return fmt.Errorf("failed to apply configuration: %w", err) } @@ -226,7 +236,9 @@ func cloud( //nolint:funlen } docker := dockercompose.NewDocker() + ce.Infoln("Downloading metadata...") + if err := docker.HasuraWrapper( ctx, ce.LocalSubdomain(), @@ -243,6 +255,7 @@ func cloud( //nolint:funlen ce.Infoln("Nhost development environment started.") printCloudInfo(ce.LocalSubdomain(), httpPort, useTLS) + return nil } diff --git a/cmd/dev/compose.go b/cmd/dev/compose.go index abcd535db..dd14b5e19 100644 --- a/cmd/dev/compose.go +++ b/cmd/dev/compose.go @@ -20,5 +20,6 @@ func CommandCompose() *cli.Command { func commandCompose(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) dc := dockercompose.New(ce.Path.WorkingDir(), ce.Path.DockerCompose(), ce.ProjectName()) + return dc.Wrapper(cCtx.Context, cCtx.Args().Slice()...) //nolint:wrapcheck } diff --git a/cmd/dev/hasura.go b/cmd/dev/hasura.go index 290113668..8eac1de89 100644 --- a/cmd/dev/hasura.go +++ b/cmd/dev/hasura.go @@ -30,6 +30,7 @@ func commandHasura(cCtx *cli.Context) error { } docker := dockercompose.NewDocker() + return docker.HasuraWrapper( //nolint:wrapcheck cCtx.Context, ce.LocalSubdomain(), diff --git a/cmd/dev/up.go b/cmd/dev/up.go index 1aabd61e8..a8bd46cd4 100644 --- a/cmd/dev/up.go +++ b/cmd/dev/up.go @@ -26,6 +26,7 @@ func deptr[T any](t *T) T { //nolint:ireturn if t == nil { return *new(T) } + return *t } @@ -147,12 +148,13 @@ func commandUp(cCtx *cli.Context) error { // projname to be root directory if !clienv.PathExists(ce.Path.NhostToml()) { - return errors.New( //nolint:goerr113 + return errors.New( //nolint:err113 "no nhost project found, please run `nhost init` or `nhost config pull`", ) } + if !clienv.PathExists(ce.Path.Secrets()) { - return errors.New( //nolint:goerr113 + return errors.New( //nolint:err113 "no secrets found, please run `nhost init` or `nhost config pull`", ) } @@ -163,6 +165,7 @@ func commandUp(cCtx *cli.Context) error { } applySeeds := cCtx.Bool(flagApplySeeds) || !clienv.PathExists(ce.Path.DotNhostFolder()) + return Up( cCtx.Context, ce, @@ -195,6 +198,7 @@ func migrations( ) error { if clienv.PathExists(filepath.Join(ce.Path.NhostFolder(), "migrations", "default")) { ce.Infoln("Applying migrations...") + if err := dc.ApplyMigrations(ctx, endpoint); err != nil { return fmt.Errorf("failed to apply migrations: %w", err) } @@ -204,6 +208,7 @@ func migrations( if clienv.PathExists(filepath.Join(ce.Path.NhostFolder(), "metadata", "version.yaml")) { ce.Infoln("Applying metadata...") + if err := dc.ApplyMetadata(ctx, endpoint); err != nil { return fmt.Errorf("failed to apply metadata: %w", err) } @@ -214,6 +219,7 @@ func migrations( if applySeeds { if clienv.PathExists(filepath.Join(ce.Path.NhostFolder(), "seeds", "default")) { ce.Infoln("Applying seeds...") + if err := dc.ApplySeeds(ctx, endpoint); err != nil { return fmt.Errorf("failed to apply seeds: %w", err) } @@ -262,6 +268,7 @@ func reload( dc *dockercompose.DockerCompose, ) error { ce.Infoln("Reapplying metadata...") + if err := dc.ReloadMetadata(ctx); err != nil { return fmt.Errorf("failed to reapply metadata: %w", err) } @@ -277,7 +284,7 @@ func parseRunServiceConfigFlag(value string) (string, string, error) { case 2: //nolint:mnd return parts[0], parts[1], nil default: - return "", "", fmt.Errorf( //nolint:goerr113 + return "", "", fmt.Errorf( //nolint:err113 "invalid run service format, must be /path/to/config.toml:overlay_name, got %s", value, ) @@ -329,6 +336,7 @@ func up( //nolint:funlen,cyclop sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) + go func() { <-sigChan cancel() @@ -349,7 +357,9 @@ func up( //nolint:funlen,cyclop ctxWithTimeout, cancel := context.WithTimeout(ctx, 5*time.Second) //nolint:mnd defer cancel() + ce.Infoln("Checking versions...") + if err := software.CheckVersions(ctxWithTimeout, ce, cfg, appVersion); err != nil { ce.Warnln("Problem verifying recommended versions: %s", err.Error()) } @@ -360,6 +370,7 @@ func up( //nolint:funlen,cyclop } ce.Infoln("Setting up Nhost development environment...") + composeFile, err := dockercompose.ComposeFileFromConfig( cfg, ce.LocalSubdomain(), @@ -381,11 +392,13 @@ func up( //nolint:funlen,cyclop if err != nil { return fmt.Errorf("failed to generate docker-compose.yaml: %w", err) } + if err := dc.WriteComposeFile(composeFile); err != nil { return fmt.Errorf("failed to write docker-compose.yaml: %w", err) } ce.Infoln("Starting Nhost development environment...") + if err = dc.Start(ctx); err != nil { return fmt.Errorf("failed to start Nhost development environment: %w", err) } @@ -399,7 +412,9 @@ func up( //nolint:funlen,cyclop } docker := dockercompose.NewDocker() + ce.Infoln("Downloading metadata...") + if err := docker.HasuraWrapper( ctx, ce.LocalSubdomain(), @@ -420,6 +435,7 @@ func up( //nolint:funlen,cyclop ce.Infoln("Nhost development environment started.") printInfo(ce.LocalSubdomain(), httpPort, postgresPort, useTLS, runServicesCfg) + return nil } @@ -493,17 +509,20 @@ func upErr( if !downOnError { ce.PromptMessage("Do you want to stop Nhost's development environment? [y/N] ") + resp, err := ce.PromptInput(false) if err != nil { ce.Warnln("failed to read input: %s", err) return nil } + if resp != "y" && resp != "Y" { return nil } } ce.Infoln("Stopping Nhost development environment...") + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() diff --git a/cmd/dockercredentials/configure.go b/cmd/dockercredentials/configure.go index f0ea32afa..fefa9f778 100644 --- a/cmd/dockercredentials/configure.go +++ b/cmd/dockercredentials/configure.go @@ -26,6 +26,7 @@ func CommandConfigure() *cli.Command { if err != nil { home = "/root" } + return &cli.Command{ //nolint:exhaustruct Name: "configure", Aliases: []string{}, @@ -56,6 +57,7 @@ func canSudo(ctx context.Context) bool { if err := exec.CommandContext(ctx, "sudo", "-n", "true").Run(); err != nil { return false } + return true } @@ -68,6 +70,7 @@ func writeScript(ctx context.Context, ce *clienv.CliEnv) error { } script := fmt.Sprintf(script, executable) + tmpfile, err := os.CreateTemp("", "nhost-docker-credentials") if err != nil { return fmt.Errorf("could not create temporary file: %w", err) @@ -85,6 +88,7 @@ func writeScript(ctx context.Context, ce *clienv.CliEnv) error { if !canSudo(ctx) { ce.Println("I need root privileges to install the file. Please, enter your password.") } + if err := exec.CommandContext( //nolint:gosec ctx, "sudo", "mv", tmpfile.Name(), credentialsPath, ).Run(); err != nil { @@ -110,6 +114,7 @@ func configureDocker(dockerConfig string) error { if !ok { credHelpers = make(map[string]interface{}) } + credHelpers["registry.ap-south-1.nhost.run"] = credentialsHelper credHelpers["registry.ap-southeast-1.nhost.run"] = credentialsHelper credHelpers["registry.eu-central-1.nhost.run"] = credentialsHelper @@ -151,10 +156,12 @@ func actionConfigure(c *cli.Context) error { "I am about to configure docker to authenticate with Nhost's registry. This will modify your docker config file on %s. Should I continue? [y/N] ", c.String(flagDockerConfig), ) + v, err := ce.PromptInput(false) if err != nil { return fmt.Errorf("could not read input: %w", err) } + if v == "y" || v == "Y" { return configureDocker(c.String(flagDockerConfig)) } diff --git a/cmd/dockercredentials/get.go b/cmd/dockercredentials/get.go index d4d26fc59..de913e430 100644 --- a/cmd/dockercredentials/get.go +++ b/cmd/dockercredentials/get.go @@ -53,6 +53,7 @@ func getToken(ctx context.Context, authURL, graphqlURL string) (string, error) { "unneeded", "unneeded", ) + session, err := ce.LoadSession(ctx) if err != nil { return "", err //nolint:wrapcheck @@ -70,10 +71,12 @@ type response struct { func actionGet(c *cli.Context) error { scanner := bufio.NewScanner(c.App.Reader) + var input string for scanner.Scan() { input += scanner.Text() } + token, err := getToken(c.Context, c.String(flagAuthURL), c.String(flagGraphqlURL)) if err != nil { return err diff --git a/cmd/project/init.go b/cmd/project/init.go index ffea78e3c..ca8bc2d61 100644 --- a/cmd/project/init.go +++ b/cmd/project/init.go @@ -30,18 +30,21 @@ func writeFiles(ps *clienv.PathStructure, root, relPath string) error { if err != nil { return fmt.Errorf("failed to read dir: %w", err) } + for _, entry := range dirEntries { if entry.IsDir() { return writeFiles(ps, root, filepath.Join(relPath, entry.Name())) } src := filepath.Join(root, relPath, entry.Name()) + fileData, err := fs.ReadFile(embeddedFS, src) if err != nil { return fmt.Errorf("failed to read file %s: %w", src, err) } dst := filepath.Join(ps.Root(), relPath, entry.Name()) + f, err := os.OpenFile( filepath.Join(ps.Root(), dst), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600, //nolint:mnd @@ -82,7 +85,7 @@ func commandInit(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) if clienv.PathExists(ce.Path.NhostFolder()) { - return errors.New("nhost folder already exists") //nolint:goerr113 + return errors.New("nhost folder already exists") //nolint:err113 } if err := os.MkdirAll(ce.Path.NhostFolder(), 0o755); err != nil { //nolint:mnd @@ -90,6 +93,7 @@ func commandInit(cCtx *cli.Context) error { } ce.Infoln("Initializing Nhost project") + if err := config.InitConfigAndSecrets(ce); err != nil { return fmt.Errorf("failed to initialize configuration: %w", err) } @@ -105,6 +109,7 @@ func commandInit(cCtx *cli.Context) error { } ce.Infoln("Successfully initialized Nhost project, run `nhost up` to start development") + return nil } @@ -181,6 +186,7 @@ func InitRemote( if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + hasuraAdminSecret, err := cl.GetHasuraAdminSecret(ctx, proj.ID) if err != nil { return fmt.Errorf("failed to get hasura admin secret: %w", err) @@ -197,6 +203,7 @@ func InitRemote( } ce.Infoln("Project initialized successfully!") + return nil } @@ -208,7 +215,9 @@ func deploy( hasuraAdminSecret string, ) error { docker := dockercompose.NewDocker() + ce.Infoln("Creating postgres migration") + if err := docker.HasuraWrapper( ctx, ce.LocalSubdomain(), @@ -225,6 +234,7 @@ func deploy( } ce.Infoln("Downloading metadata...") + if err := docker.HasuraWrapper( ctx, ce.LocalSubdomain(), diff --git a/cmd/project/link.go b/cmd/project/link.go index dfbc910c5..2ac7b1e44 100644 --- a/cmd/project/link.go +++ b/cmd/project/link.go @@ -26,5 +26,6 @@ func commandLink(cCtx *cli.Context) error { } _, err := ce.Link(cCtx.Context) + return err //nolint:wrapcheck } diff --git a/cmd/project/list.go b/cmd/project/list.go index bfc7a5f5b..b472b9247 100644 --- a/cmd/project/list.go +++ b/cmd/project/list.go @@ -28,6 +28,7 @@ func List(ctx context.Context, ce *clienv.CliEnv) error { if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + orgs, err := cl.GetOrganizationsAndWorkspacesApps(ctx) if err != nil { return fmt.Errorf("failed to get workspaces: %w", err) diff --git a/cmd/run/config_deploy.go b/cmd/run/config_deploy.go index 09409c89f..a95c4f22c 100644 --- a/cmd/run/config_deploy.go +++ b/cmd/run/config_deploy.go @@ -51,6 +51,7 @@ func transform[T, V any](t *T) (*V, error) { func commandConfigDeploy(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) + cl, err := ce.GetNhostClient(cCtx.Context) if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) diff --git a/cmd/run/config_edit.go b/cmd/run/config_edit.go index 0074c91a7..aa8c05d89 100644 --- a/cmd/run/config_edit.go +++ b/cmd/run/config_edit.go @@ -53,6 +53,7 @@ func commandConfigEdit(cCtx *cli.Context) error { ); err != nil { return fmt.Errorf("failed to edit config: %w", err) } + return nil } diff --git a/cmd/run/config_pull.go b/cmd/run/config_pull.go index 96d6d96bf..e5adcd45e 100644 --- a/cmd/run/config_pull.go +++ b/cmd/run/config_pull.go @@ -38,6 +38,7 @@ func CommandConfigPull() *cli.Command { func commandConfigPull(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) + cl, err := ce.GetNhostClient(cCtx.Context) if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) diff --git a/cmd/run/config_show.go b/cmd/run/config_show.go index 783aaa12c..02b89dba1 100644 --- a/cmd/run/config_show.go +++ b/cmd/run/config_show.go @@ -62,5 +62,6 @@ func commandConfigShow(cCtx *cli.Context) error { } ce.Println("%s", b) + return nil } diff --git a/cmd/run/config_validate.go b/cmd/run/config_validate.go index df4e1ce2b..458dc6955 100644 --- a/cmd/run/config_validate.go +++ b/cmd/run/config_validate.go @@ -59,6 +59,7 @@ func respToSecrets(env []*graphql.GetSecrets_AppSecrets) model.Secrets { Value: s.Value, } } + return secrets } @@ -127,6 +128,7 @@ func Validate( if err != nil { return nil, fmt.Errorf("failed to validate config: %w", err) } + if !testSecretsOnly { cfg = cfgSecretsResolved } @@ -143,6 +145,7 @@ func getRemoteSecrets( if err != nil { return nil, "", err } + secretsResp, err := cl.GetSecrets( ctx, appID, @@ -155,11 +158,14 @@ func getRemoteSecrets( } func commandConfigValidate(cCtx *cli.Context) error { - var overlayName string - var serviceID string + var ( + overlayName string + serviceID string + ) + switch { case cCtx.String(flagServiceID) != "" && cCtx.String(flagOverlayName) != "": - return errors.New("cannot specify both service id and overlay name") //nolint:goerr113 + return errors.New("cannot specify both service id and overlay name") //nolint:err113 case cCtx.String(flagServiceID) != "": serviceID = cCtx.String(flagServiceID) overlayName = serviceID @@ -170,12 +176,15 @@ func commandConfigValidate(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) var secrets model.Secrets + ce.Infoln("Getting secrets...") + if serviceID != "" { cl, err := ce.GetNhostClient(cCtx.Context) if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + secrets, _, err = getRemoteSecrets(cCtx.Context, cl, serviceID) if err != nil { return err @@ -190,6 +199,7 @@ func commandConfigValidate(cCtx *cli.Context) error { } ce.Infoln("Verifying configuration...") + if _, err := Validate( ce, cCtx.String(flagConfig), @@ -201,5 +211,6 @@ func commandConfigValidate(cCtx *cli.Context) error { } ce.Infoln("Configuration is valid!") + return nil } diff --git a/cmd/secrets/create.go b/cmd/secrets/create.go index 9def03db9..5a12fba49 100644 --- a/cmd/secrets/create.go +++ b/cmd/secrets/create.go @@ -21,10 +21,11 @@ func CommandCreate() *cli.Command { func commandCreate(cCtx *cli.Context) error { if cCtx.NArg() != 2 { //nolint:mnd - return errors.New("invalid number of arguments") //nolint:goerr113 + return errors.New("invalid number of arguments") //nolint:err113 } ce := clienv.FromCLI(cCtx) + proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain)) if err != nil { return fmt.Errorf("failed to get app info: %w", err) @@ -34,6 +35,7 @@ func commandCreate(cCtx *cli.Context) error { if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + if _, err := cl.CreateSecret( cCtx.Context, proj.ID, diff --git a/cmd/secrets/delete.go b/cmd/secrets/delete.go index c0b187d39..66f47d805 100644 --- a/cmd/secrets/delete.go +++ b/cmd/secrets/delete.go @@ -21,10 +21,11 @@ func CommandDelete() *cli.Command { func commandDelete(cCtx *cli.Context) error { if cCtx.NArg() != 1 { - return errors.New("invalid number of arguments") //nolint:goerr113 + return errors.New("invalid number of arguments") //nolint:err113 } ce := clienv.FromCLI(cCtx) + proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain)) if err != nil { return fmt.Errorf("failed to get app info: %w", err) @@ -34,6 +35,7 @@ func commandDelete(cCtx *cli.Context) error { if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + if _, err := cl.DeleteSecret( cCtx.Context, proj.ID, diff --git a/cmd/secrets/list.go b/cmd/secrets/list.go index 06e108fc2..bdd31195d 100644 --- a/cmd/secrets/list.go +++ b/cmd/secrets/list.go @@ -29,6 +29,7 @@ func commandList(cCtx *cli.Context) error { if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + secrets, err := cl.GetSecrets( cCtx.Context, proj.ID, diff --git a/cmd/secrets/update.go b/cmd/secrets/update.go index 5f7f49cbd..9e72a178b 100644 --- a/cmd/secrets/update.go +++ b/cmd/secrets/update.go @@ -21,10 +21,11 @@ func CommandUpdate() *cli.Command { func commandUpdate(cCtx *cli.Context) error { if cCtx.NArg() != 2 { //nolint:mnd - return errors.New("invalid number of arguments") //nolint:goerr113 + return errors.New("invalid number of arguments") //nolint:err113 } ce := clienv.FromCLI(cCtx) + proj, err := ce.GetAppInfo(cCtx.Context, cCtx.String(flagSubdomain)) if err != nil { return fmt.Errorf("failed to get app info: %w", err) @@ -34,6 +35,7 @@ func commandUpdate(cCtx *cli.Context) error { if err != nil { return fmt.Errorf("failed to get nhost client: %w", err) } + if _, err := cl.UpdateSecret( cCtx.Context, proj.ID, diff --git a/cmd/software/uninstall.go b/cmd/software/uninstall.go index b9a082b80..6656ab7f6 100644 --- a/cmd/software/uninstall.go +++ b/cmd/software/uninstall.go @@ -46,6 +46,7 @@ func commandUninstall(cCtx *cli.Context) error { if !cCtx.Bool(forceFlag) { ce.PromptMessage("Are you sure you want to uninstall Nhost CLI? [y/N] ") + resp, err := ce.PromptInput(false) if err != nil { return fmt.Errorf("failed to read user input: %w", err) @@ -57,6 +58,7 @@ func commandUninstall(cCtx *cli.Context) error { } ce.Infoln("Uninstalling Nhost CLI...") + if err := os.Remove(path); err != nil { return fmt.Errorf("failed to remove CLI: %w", err) } diff --git a/cmd/software/upgrade.go b/cmd/software/upgrade.go index 40664ffd8..7b6f71ca2 100644 --- a/cmd/software/upgrade.go +++ b/cmd/software/upgrade.go @@ -23,6 +23,7 @@ func commandUpgrade(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) mgr := software.NewManager() + releases, err := mgr.GetReleases(cCtx.Context, cCtx.App.Version) if err != nil { return fmt.Errorf("failed to get releases: %w", err) @@ -42,7 +43,9 @@ func commandUpgrade(cCtx *cli.Context) error { ce.Infoln("Upgrading to %s...", latest.TagName) want := fmt.Sprintf("cli-%s-%s-%s.tar.gz", latest.TagName, runtime.GOOS, runtime.GOARCH) + var url string + for _, asset := range latest.Assets { if asset.Name == want { url = asset.BrowserDownloadURL @@ -50,7 +53,7 @@ func commandUpgrade(cCtx *cli.Context) error { } if url == "" { - return fmt.Errorf("failed to find asset for %s", want) //nolint:goerr113 + return fmt.Errorf("failed to find asset for %s", want) //nolint:err113 } tmpFile, err := os.CreateTemp(os.TempDir(), "nhost-cli-") @@ -79,11 +82,13 @@ func install(cCtx *cli.Context, ce *clienv.CliEnv, tmpFile string) error { } ce.Infoln("Copying to %s...", curBin) + if err := os.Rename(tmpFile, curBin); err != nil { return fmt.Errorf("failed to rename %s to %s: %w", tmpFile, curBin, err) } ce.Infoln("Setting permissions...") + if err := os.Chmod(curBin, 0o755); err != nil { //nolint:mnd return fmt.Errorf("failed to set permissions on %s: %w", curBin, err) } diff --git a/cmd/software/version.go b/cmd/software/version.go index 7c4c5fb72..1cf245ce9 100644 --- a/cmd/software/version.go +++ b/cmd/software/version.go @@ -30,6 +30,7 @@ func checkCLIVersion( curVersion string, ) error { mgr := software.NewManager() + releases, err := mgr.GetReleases(ctx, curVersion) if err != nil { return fmt.Errorf("failed to get releases: %w", err) @@ -40,6 +41,7 @@ func checkCLIVersion( "✅ Nhost CLI %s for %s-%s is already on the latest version", curVersion, runtime.GOOS, runtime.GOARCH, ) + return nil } @@ -63,6 +65,7 @@ func checkServiceVersion( changelog string, ) { recommendedVersions := make([]string, 0, 5) //nolint:mnd + for _, v := range availableVersions.GetSoftwareVersions() { if *v.GetSoftware() == software && v.GetVersion() == curVersion { ce.Infoln("✅ %s is already on a recommended version: %s", software, curVersion) @@ -71,10 +74,12 @@ func checkServiceVersion( recommendedVersions = append(recommendedVersions, v.GetVersion()) } } + ce.Warnln( "🟡 %s is not on a recommended version. Recommended: %s", software, strings.Join(recommendedVersions, ", "), ) + if changelog != "" { ce.Println(" More info: %s", changelog) } @@ -130,8 +135,11 @@ func CheckVersions( func commandVersion(cCtx *cli.Context) error { ce := clienv.FromCLI(cCtx) - var cfg *model.ConfigConfig - var err error + var ( + cfg *model.ConfigConfig + err error + ) + if clienv.PathExists(ce.Path.NhostToml()) && clienv.PathExists(ce.Path.Secrets()) { var secrets model.Secrets if err := clienv.UnmarshalFile(ce.Path.Secrets(), &secrets, env.Unmarshal); err != nil { diff --git a/cmd/user/login.go b/cmd/user/login.go index bd990c0ea..e19d16385 100644 --- a/cmd/user/login.go +++ b/cmd/user/login.go @@ -42,5 +42,6 @@ func commandLogin(cCtx *cli.Context) error { _, err := ce.Login( cCtx.Context, cCtx.String(flagPAT), cCtx.String(flagEmail), cCtx.String(flagPassword), ) + return err //nolint:wrapcheck } diff --git a/dockercompose/auth.go b/dockercompose/auth.go index 4c9c42b14..323e8a859 100644 --- a/dockercompose/auth.go +++ b/dockercompose/auth.go @@ -61,6 +61,7 @@ func auth( //nolint:funlen for _, v := range envars { env[v.Name] = v.Value } + svc := &Service{ Image: "nhost/hasura-auth:" + *cfg.Auth.Version, DependsOn: map[string]DependsOn{ diff --git a/dockercompose/auth_test.go b/dockercompose/auth_test.go index 7a54d9f86..084200e14 100644 --- a/dockercompose/auth_test.go +++ b/dockercompose/auth_test.go @@ -38,6 +38,7 @@ func expectedAuth() *Service { "AUTH_GRAVATAR_RATING": "gravatarRating", "AUTH_HOST": "0.0.0.0", "AUTH_JWT_CUSTOM_CLAIMS": `{"customClaimKey":"customClaimValue"}`, + "AUTH_JWT_CUSTOM_CLAIMS_DEFAULTS": `{}`, "AUTH_LOCALE_ALLOWED_LOCALES": "en,se,ca,es", "AUTH_LOCALE_DEFAULT": "en", "AUTH_MFA_ENABLED": "true", diff --git a/dockercompose/compose.go b/dockercompose/compose.go index c7a0af329..708327d38 100644 --- a/dockercompose/compose.go +++ b/dockercompose/compose.go @@ -45,6 +45,7 @@ func ports(host, container uint) []Port { if host == 0 { return nil } + return []Port{ { Mode: "ingress", @@ -224,6 +225,7 @@ func traefik(subdomain, projectName string, port uint, dotnhostfolder string) (* if err := trafikFiles(dotnhostfolder); err != nil { return nil, fmt.Errorf("failed to create traefik files: %w", err) } + dockerURL, err := getDockerHost() if err != nil { return nil, fmt.Errorf("failed to get docker host: %w", err) @@ -507,6 +509,7 @@ func IsJWTSecretCompatibleWithHasuraAuth( //nolint:cyclop *jwtSecret.Type == "HS512" || *jwtSecret.Type == "RS256" || *jwtSecret.Type == "RS384" || *jwtSecret.Type == "RS512" } + return false } @@ -537,6 +540,7 @@ func getServices( //nolint: funlen,cyclop pgVolumeName := "pgdata_" + sanitizeBranch(branch) dataFolder := filepath.Join(dotNhostFolder, "data") + postgres, err := postgres(cfg, subdomain, postgresPort, dataFolder, pgVolumeName) if err != nil { return nil, err @@ -546,6 +550,7 @@ func getServices( //nolint: funlen,cyclop if err != nil { return nil, err } + jwtSecret := graphql.Environment["HASURA_GRAPHQL_JWT_SECRET"] console, err := console(cfg, subdomain, httpPort, useTLS, nhostFolder, ports.Console) @@ -598,6 +603,7 @@ func getServices( //nolint: funlen,cyclop if err != nil { return nil, err } + services["auth"] = auth if cfg.Ai != nil { diff --git a/dockercompose/configserver.go b/dockercompose/configserver.go index c6bcf3c32..19fb5fabc 100644 --- a/dockercompose/configserver.go +++ b/dockercompose/configserver.go @@ -14,6 +14,7 @@ func configserver( //nolint: funlen ) *Service { bindings := make([]Volume, 0, len(runServices)) extraArgs := make([]string, len(runServices)) + mountedVolumes := make([]string, 0, len(runServices)) for i, runService := range runServices { source := filepath.Dir(runService.Path) @@ -25,6 +26,7 @@ func configserver( //nolint: funlen if slices.Contains(mountedVolumes, source) { continue } + mountedVolumes = append(mountedVolumes, source) bindings = append(bindings, Volume{ diff --git a/dockercompose/docker.go b/dockercompose/docker.go index 530f58bfb..fd067a2f8 100644 --- a/dockercompose/docker.go +++ b/dockercompose/docker.go @@ -30,6 +30,7 @@ func (d *Docker) HasuraWrapper( if err != nil { return fmt.Errorf("failed to get absolute path: %w", err) } + args := []string{ "run", "-v", absPath + ":/app", @@ -70,5 +71,6 @@ func (d *Docker) HasuraWrapper( return fmt.Errorf("failed to copy pty output: %w", err) } } + return nil } diff --git a/dockercompose/dockercompose.go b/dockercompose/dockercompose.go index 796dc552d..82876c7fa 100644 --- a/dockercompose/dockercompose.go +++ b/dockercompose/dockercompose.go @@ -65,6 +65,7 @@ func (dc *DockerCompose) Start(ctx context.Context) error { if err := cmd.Run(); err != nil { return fmt.Errorf("failed to start docker compose: %w", err) } + return nil } @@ -80,12 +81,14 @@ func (dc *DockerCompose) Stop(ctx context.Context, volumes bool) error { if volumes { cmd.Args = append(cmd.Args, "--volumes") } + cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { return fmt.Errorf("failed to stop docker compose: %w", err) } + return nil } @@ -110,6 +113,7 @@ func (dc *DockerCompose) Logs(ctx context.Context, extraArgs ...string) error { if err := cmd.Run(); err != nil { return fmt.Errorf("failed to show logs from docker compose: %w", err) } + return nil } @@ -133,6 +137,7 @@ func (dc *DockerCompose) Wrapper(ctx context.Context, extraArgs ...string) error if err := cmd.Run(); err != nil { return fmt.Errorf("failed to run docker compose: %w", err) } + return nil } @@ -226,6 +231,7 @@ func (dc *DockerCompose) ApplyMigrations(ctx context.Context, endpoint string) e return fmt.Errorf("failed to copy pty output: %w", err) } } + return nil } @@ -262,5 +268,6 @@ func (dc *DockerCompose) ApplySeeds(ctx context.Context, endpoint string) error return fmt.Errorf("failed to copy pty output: %w", err) } } + return nil } diff --git a/dockercompose/graphql.go b/dockercompose/graphql.go index 73f835e07..fb1ac5b07 100644 --- a/dockercompose/graphql.go +++ b/dockercompose/graphql.go @@ -34,6 +34,7 @@ func graphql( //nolint:funlen v.Value += "," + URL("*", "hasura", httpPort, useTLS) v.Value += "," + URL("*", "dashboard", httpPort, useTLS) } + env[v.Name] = v.Value } @@ -94,7 +95,7 @@ func console( //nolint:funlen port uint, ) (*Service, error) { if semver.Compare(*cfg.GetHasura().GetVersion(), minimumHasuraVerson) < 0 { - return nil, fmt.Errorf( //nolint:goerr113 + return nil, fmt.Errorf( //nolint:err113 "hasura version must be at least %s", minimumHasuraVerson, ) @@ -130,6 +131,7 @@ func console( //nolint:funlen if v.Name == "HASURA_GRAPHQL_CORS_DOMAIN" && v.Value != "*" { v.Value += "," + URL("*", "hasura", httpPort, useTLS) } + env[v.Name] = v.Value } diff --git a/dockercompose/ingress.go b/dockercompose/ingress.go index 6885dfa1e..e518e6ad7 100644 --- a/dockercompose/ingress.go +++ b/dockercompose/ingress.go @@ -10,11 +10,13 @@ type Ingresses []Ingress func (i Ingresses) Labels() map[string]string { labels := make(map[string]string) labels["traefik.enable"] = "true" + for _, ingress := range i { for k, v := range ingress.Labels() { labels[k] = v } } + return labels } diff --git a/dockercompose/postgres.go b/dockercompose/postgres.go index aa2d1f501..ba9e8e01d 100644 --- a/dockercompose/postgres.go +++ b/dockercompose/postgres.go @@ -46,6 +46,7 @@ func postgres( //nolint:funlen for _, v := range envars { env[v.Name] = v.Value } + env["POSTGRES_DEV_INSECURE"] = "true" return &Service{ diff --git a/dockercompose/postgres_test.go b/dockercompose/postgres_test.go index 5bb648be5..d6f66b54e 100644 --- a/dockercompose/postgres_test.go +++ b/dockercompose/postgres_test.go @@ -87,6 +87,7 @@ func TestPostgres(t *testing.T) { t.Parallel() tmpdir := filepath.Join(os.TempDir(), "data") + got, err := postgres(tc.cfg(), "dev", 5432, tmpdir, "pgdate_test") if err != nil { t.Errorf("got error: %v", err) diff --git a/dockercompose/run.go b/dockercompose/run.go index 7f468a657..d42c8304b 100644 --- a/dockercompose/run.go +++ b/dockercompose/run.go @@ -32,6 +32,7 @@ func run( if p.GetType() == "udp" { proto = p.GetType() } + ports = append(ports, Port{ Mode: "ingress", Target: uint(p.GetPort()), diff --git a/dockercompose/storage.go b/dockercompose/storage.go index 42c275605..460f4f447 100644 --- a/dockercompose/storage.go +++ b/dockercompose/storage.go @@ -11,6 +11,7 @@ func deptr[T any](t *T) T { //nolint:ireturn if t == nil { return *new(T) } + return *t } diff --git a/dockercompose/url.go b/dockercompose/url.go index 74ad62817..12ca946c0 100644 --- a/dockercompose/url.go +++ b/dockercompose/url.go @@ -13,5 +13,6 @@ func URL(host, service string, port uint, useTLS bool) string { if useTLS { protocol = schemeHTTPS } + return fmt.Sprintf("%s://%s.%s.local.nhost.run:%d", protocol, host, service, port) } diff --git a/examples/myproject/nhost/metadata/databases/default/tables/auth_users.yaml b/examples/myproject/nhost/metadata/databases/default/tables/auth_users.yaml index 730001730..df96a47a2 100644 --- a/examples/myproject/nhost/metadata/databases/default/tables/auth_users.yaml +++ b/examples/myproject/nhost/metadata/databases/default/tables/auth_users.yaml @@ -92,6 +92,13 @@ object_relationships: using: foreign_key_constraint_on: default_role array_relationships: + - name: animals + using: + foreign_key_constraint_on: + column: user_id + table: + name: animals + schema: public - name: refreshTokens using: foreign_key_constraint_on: diff --git a/examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/down.sql b/examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/down.sql new file mode 100644 index 000000000..e6ed6ba13 --- /dev/null +++ b/examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."animals" add column "user_id" uuid +-- null; diff --git a/examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/up.sql b/examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/up.sql new file mode 100644 index 000000000..746cfb266 --- /dev/null +++ b/examples/myproject/nhost/migrations/default/1753779357316_alter_table_public_animals_add_column_user_id/up.sql @@ -0,0 +1,2 @@ +alter table "public"."animals" add column "user_id" uuid + null; diff --git a/examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/down.sql b/examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/down.sql new file mode 100644 index 000000000..963055138 --- /dev/null +++ b/examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/down.sql @@ -0,0 +1 @@ +alter table "public"."animals" drop constraint "animals_user_id_fkey"; diff --git a/examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/up.sql b/examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/up.sql new file mode 100644 index 000000000..7bee61c0b --- /dev/null +++ b/examples/myproject/nhost/migrations/default/1753779380523_set_fk_public_animals_user_id/up.sql @@ -0,0 +1,5 @@ +alter table "public"."animals" + add constraint "animals_user_id_fkey" + foreign key ("user_id") + references "auth"."users" + ("id") on update set null on delete set null; diff --git a/examples/myproject/nhost/nhost.toml b/examples/myproject/nhost/nhost.toml index 4d306b9e0..3372ce75a 100644 --- a/examples/myproject/nhost/nhost.toml +++ b/examples/myproject/nhost/nhost.toml @@ -24,7 +24,7 @@ liveQueriesMultiplexedRefetchInterval = 3000 version = 22 [auth] -version = '0.40.0' +version = '0.41.0' [auth.redirections] clientUrl = 'http://localhost:3000' @@ -54,6 +54,11 @@ rating = 'g' [auth.session.accessToken] expiresIn = 900 +[[auth.session.accessToken.customClaims]] +key = "spirit-animal" +value = "animals[0].id" +default = "00000000-0000-0000-0000-000000000000" + [auth.session.refreshToken] expiresIn = 2592000 @@ -66,7 +71,7 @@ enabled = false [auth.method.emailPassword] hibpEnabled = false -emailVerificationRequired = true +emailVerificationRequired = false passwordMinLength = 9 [auth.method.smsPasswordless] @@ -129,7 +134,7 @@ timeout = 60000 enabled = false [postgres] -version = '14.15-20250311-1' +version = '14.18-20250728-1' [postgres.resources.storage] capacity = 1 diff --git a/flake.lock b/flake.lock index f4a0f9878..6ff5090eb 100644 --- a/flake.lock +++ b/flake.lock @@ -41,11 +41,11 @@ ] }, "locked": { - "lastModified": 1749158376, - "narHash": "sha256-uirStFNxauh0lxzBowcp28X+Sq7JgsBIDnbwbAfZwf8=", + "lastModified": 1752002763, + "narHash": "sha256-JYAkdZvpdSx9GUoHPArctYMypSONob4DYKRkOubUWtY=", "owner": "nlewo", "repo": "nix2container", - "rev": "0f8974c58755dba441df03598eefd1e1cd50e341", + "rev": "4f2437f6a1844b843b380d483087ae6d461240ee", "type": "github" }, "original": { @@ -62,11 +62,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1750077810, - "narHash": "sha256-MsaskaJ+a0O06SZ6eVLfhx+oMcO6R8PFlyBpRwnMn8E=", + "lastModified": 1753702347, + "narHash": "sha256-GWC87trB+nsaYpL/JIjqXSnJcuYK2dQNxV3bnc0e0fE=", "owner": "nhost", "repo": "nixops", - "rev": "1ed1112322d418277f25f4a13f6b0f2f5928fa6e", + "rev": "67f32474b9f76daa1538120eaa5dafd58ee3169b", "type": "github" }, "original": { @@ -77,11 +77,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1745804731, - "narHash": "sha256-v/sK3AS0QKu/Tu5sHIfddiEHCvrbNYPv8X10Fpux68g=", + "lastModified": 1753399495, + "narHash": "sha256-7XG/QBqhrYOyA2houjRTL2NMa7IKZZ/somBqr+Q/6Wo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "29335f23bea5e34228349ea739f31ee79e267b88", + "rev": "0d00f23f023b7215b3f1035adb5247c8ec180dbc", "type": "github" }, "original": { diff --git a/go.mod b/go.mod index 3a4364114..b20478b85 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.24.2 replace cuelang.org/go => cuelang.org/go v0.4.3 require ( - github.com/99designs/gqlgen v0.17.73 - github.com/Yamashou/gqlgenc v0.32.1 + github.com/99designs/gqlgen v0.17.76 + github.com/Yamashou/gqlgenc v0.33.0 github.com/charmbracelet/lipgloss v1.1.0 github.com/creack/pty v1.1.24 github.com/gin-gonic/gin v1.10.0 @@ -14,13 +14,13 @@ require ( github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/hashicorp/go-getter v1.7.8 - github.com/nhost/be v0.0.0-20250530082915-10b936caf233 + github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb github.com/pelletier/go-toml/v2 v2.2.4 github.com/rs/cors/wrapper/gin v0.0.0-20240830163046-1084d89a1692 github.com/sirupsen/logrus v1.9.3 - github.com/urfave/cli/v2 v2.27.6 + github.com/urfave/cli/v2 v2.27.7 github.com/wI2L/jsondiff v0.6.1 - golang.org/x/mod v0.24.0 + golang.org/x/mod v0.25.0 golang.org/x/term v0.32.0 gopkg.in/evanphx/json-patch.v5 v5.9.11 gopkg.in/yaml.v3 v3.0.1 @@ -74,7 +74,7 @@ require ( github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.26.0 // indirect - github.com/go-viper/mapstructure/v2 v2.2.1 // indirect + github.com/go-viper/mapstructure/v2 v2.3.0 // indirect github.com/goccy/go-json v0.10.5 // indirect github.com/golang-jwt/jwt/v5 v5.2.2 // indirect github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect @@ -129,7 +129,7 @@ require ( github.com/ulikunitz/xz v0.5.12 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - github.com/vektah/gqlparser/v2 v2.5.26 // indirect + github.com/vektah/gqlparser/v2 v2.5.30 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect @@ -144,12 +144,12 @@ require ( go.opentelemetry.io/otel/sdk/metric v1.35.0 // indirect go.opentelemetry.io/otel/trace v1.35.0 // indirect golang.org/x/arch v0.17.0 // indirect - golang.org/x/crypto v0.38.0 // indirect - golang.org/x/net v0.40.0 // indirect + golang.org/x/crypto v0.39.0 // indirect + golang.org/x/net v0.41.0 // indirect golang.org/x/oauth2 v0.30.0 // indirect - golang.org/x/sync v0.14.0 // indirect + golang.org/x/sync v0.15.0 // indirect golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect + golang.org/x/text v0.26.0 // indirect golang.org/x/time v0.11.0 // indirect google.golang.org/api v0.231.0 // indirect google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 // indirect diff --git a/go.sum b/go.sum index 176c3e458..2114c608f 100644 --- a/go.sum +++ b/go.sum @@ -621,8 +621,8 @@ dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= -github.com/99designs/gqlgen v0.17.73 h1:A3Ki+rHWqKbAOlg5fxiZBnz6OjW3nwupDHEG15gEsrg= -github.com/99designs/gqlgen v0.17.73/go.mod h1:2RyGWjy2k7W9jxrs8MOQthXGkD3L3oGr0jXW3Pu8lGg= +github.com/99designs/gqlgen v0.17.76 h1:YsJBcfACWmXWU2t1yCjoGdOmqcTfOFpjbLAE443fmYI= +github.com/99designs/gqlgen v0.17.76/go.mod h1:miiU+PkAnTIDKMQ1BseUOIVeQHoiwYDZGCswoxl7xec= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.27.0 h1:ErKg/3iS1AKcTkf3yixlZ54f9U1rljCkQyEXWUnIUxc= @@ -642,8 +642,8 @@ github.com/ProtonMail/go-crypto v1.2.0 h1:+PhXXn4SPGd+qk76TlEePBfOfivE0zkWFenhGh github.com/ProtonMail/go-crypto v1.2.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE= github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo= github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y= -github.com/Yamashou/gqlgenc v0.32.1 h1:EHs9//xQxXlyltkSFXM+fhO2rTXcWNw6FPKRJ6t+iQQ= -github.com/Yamashou/gqlgenc v0.32.1/go.mod h1:o5SxKt9d3+oUZ2i0V3CW8lHFyunfLR+KcKHubS4zf5E= +github.com/Yamashou/gqlgenc v0.33.0 h1:0fxTnNE8/JVmFpfo7reA5pEgOcr7VjNc+/nEpVhNjfc= +github.com/Yamashou/gqlgenc v0.33.0/go.mod h1:MZGXx/nALyxcehcFeLGmYiNsJ+hQTOGJzNYCGNX4rL0= github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM= github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= @@ -819,8 +819,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= -github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= -github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk= +github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= @@ -1044,10 +1044,8 @@ github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/nhost/be v0.0.0-20250506064156-ba09da107493 h1:zu4fe9HBPvWGaJpfp2QG2ncIdERmUbNIyJLVRR2kntk= -github.com/nhost/be v0.0.0-20250506064156-ba09da107493/go.mod h1:6cXrYoPv/GuHNC+wzvOMyK/ou53HZlMT2FTq4zZEVUs= -github.com/nhost/be v0.0.0-20250530082915-10b936caf233 h1:SQiXoC8xKj5nIMS1dUNOVYhnsRCKB/wduDpMHudXaL8= -github.com/nhost/be v0.0.0-20250530082915-10b936caf233/go.mod h1:4lGRV082oUQvbDBilu4pwFgIhIrEoxtGKjtZo9U4CIA= +github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb h1:ftbYufoc6iZA2jHOgjcsuraYbnvWzKFX4DoqGts9C4c= +github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb/go.mod h1:Btk2JXy1ih/+VTlNItNNFfhOTZlKlrodBqXaJ+2K7Pg= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= @@ -1148,14 +1146,14 @@ github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g= -github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ= +github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= +github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/vektah/gqlparser/v2 v2.5.26 h1:REqqFkO8+SOEgZHR/eHScjjVjGS8Nk3RMO/juiTobN4= -github.com/vektah/gqlparser/v2 v2.5.26/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= +github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE= +github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo= github.com/wI2L/jsondiff v0.6.1 h1:ISZb9oNWbP64LHnu4AUhsMF5W0FIj5Ok3Krip9Shqpw= github.com/wI2L/jsondiff v0.6.1/go.mod h1:KAEIojdQq66oJiHhDyQez2x+sRit0vIzC9KeK0yizxM= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -1224,8 +1222,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1288,8 +1286,8 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= -golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= +golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1353,8 +1351,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1406,8 +1404,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= -golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1531,8 +1529,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1604,8 +1602,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= -golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= +golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= +golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/main.go b/main.go index 06e4a643f..4afb71621 100644 --- a/main.go +++ b/main.go @@ -76,6 +76,7 @@ func main() { if errors.As(err, &graphqlErr) { log.Fatal(graphqlErr.GqlErrors) } + log.Fatal(err) } } diff --git a/nhostclient/auth.go b/nhostclient/auth.go index 21571bb20..414fdba91 100644 --- a/nhostclient/auth.go +++ b/nhostclient/auth.go @@ -105,7 +105,7 @@ func (n *Client) LoginPAT(ctx context.Context, pat string) (credentials.Session, func(resp *http.Response) error { if resp.StatusCode != http.StatusOK { b, _ := io.ReadAll(resp.Body) - return fmt.Errorf("unexpected status code: %d, message: %s", resp.StatusCode, string(b)) //nolint:goerr113 + return fmt.Errorf("unexpected status code: %d, message: %s", resp.StatusCode, string(b)) //nolint:err113 } return nil }, @@ -145,7 +145,7 @@ func (n *Client) CreatePAT( func(resp *http.Response) error { if resp.StatusCode != http.StatusOK { b, _ := io.ReadAll(resp.Body) - return fmt.Errorf("unexpected status code: %d, message: %s", resp.StatusCode, string(b)) //nolint:goerr113 + return fmt.Errorf("unexpected status code: %d, message: %s", resp.StatusCode, string(b)) //nolint:err113 } return nil }, @@ -170,6 +170,7 @@ func (n *Client) Logout(ctx context.Context, refreshTokenID string, accessToken ); err != nil { return fmt.Errorf("failed to delete refresh token: %w", err) } + return nil } @@ -199,7 +200,7 @@ func (n *Client) RefreshToken( func(resp *http.Response) error { if resp.StatusCode != http.StatusOK { b, _ := io.ReadAll(resp.Body) - return fmt.Errorf("unexpected status code: %d, message: %s", resp.StatusCode, string(b)) //nolint:goerr113 + return fmt.Errorf("unexpected status code: %d, message: %s", resp.StatusCode, string(b)) //nolint:err113 } return nil }, diff --git a/nhostclient/nhostclient.go b/nhostclient/nhostclient.go index e04861f73..3d6603cf9 100644 --- a/nhostclient/nhostclient.go +++ b/nhostclient/nhostclient.go @@ -17,9 +17,10 @@ const ( ) type Client struct { + *graphql.Client + baseURL string client *http.Client - *graphql.Client retryer BasicRetryer } diff --git a/nhostclient/request.go b/nhostclient/request.go index f958a80da..33fe69b2c 100644 --- a/nhostclient/request.go +++ b/nhostclient/request.go @@ -30,12 +30,14 @@ func MakeJSONRequest( if err != nil { return fmt.Errorf("failed to marshal request body: %w", err) } + body := io.NopCloser(bytes.NewReader(b)) req, err := http.NewRequestWithContext(ctx, method, url, body) if err != nil { return fmt.Errorf("failed to create request: %w", err) } + req.Header = headers req.Header.Set("Content-Type", "application/json") req.Header.Set("X-Request-Attempt", strconv.Itoa(attempt)) @@ -50,6 +52,7 @@ func MakeJSONRequest( return fmt.Errorf("request validation failed: %w", err) } } + defer resp.Body.Close() b, err = io.ReadAll(resp.Body) diff --git a/nhostclient/request_test.go b/nhostclient/request_test.go index bcb8426d0..a4e0bb109 100644 --- a/nhostclient/request_test.go +++ b/nhostclient/request_test.go @@ -71,6 +71,7 @@ func TestMakeJSONRequest(t *testing.T) { r.Method, ) } + if diff := cmp.Diff(tc.headers, r.Header); diff != "" { t.Errorf("%s", diff) } @@ -86,6 +87,7 @@ func TestMakeJSONRequest(t *testing.T) { w.WriteHeader(http.StatusOK) w.Header().Set("Content-Type", "application/json") + if err := json.NewEncoder(w).Encode(tc.expectedResponsePayload); err != nil { t.Errorf("failed to encode response body: %v", err) } @@ -93,6 +95,7 @@ func TestMakeJSONRequest(t *testing.T) { defer ts.Close() var responsePayload any + err := nhostclient.MakeJSONRequest( t.Context(), &http.Client{}, //nolint: exhaustruct diff --git a/nhostclient/retryer.go b/nhostclient/retryer.go index 8a8589ca3..5b85151a6 100644 --- a/nhostclient/retryer.go +++ b/nhostclient/retryer.go @@ -24,6 +24,7 @@ func (s BasicRetryer) Retry(f Func) error { } var err error + for i := 2; i <= s.maxAttempts; i++ { time.Sleep(time.Duration(i-1*s.multiplier) * time.Second) @@ -32,5 +33,6 @@ func (s BasicRetryer) Retry(f Func) error { return nil } } + return err } diff --git a/nhostclient/retryer_test.go b/nhostclient/retryer_test.go index 6b3babf6c..f67bb02bc 100644 --- a/nhostclient/retryer_test.go +++ b/nhostclient/retryer_test.go @@ -89,6 +89,7 @@ func TestStandardRetry(t *testing.T) { start := time.Now() calls := 0 + err := retryer.Retry(tc.funcType(t, &calls)) if !errors.Is(err, tc.expectedError) { t.Errorf("expected error %v, got %v", tc.expectedError, err) diff --git a/project/env/marshal.go b/project/env/marshal.go index 7b21e0339..e97db1eb6 100644 --- a/project/env/marshal.go +++ b/project/env/marshal.go @@ -40,6 +40,7 @@ func Unmarshal(data []byte, v any) error { }, ) } + return nil default: return toml.Unmarshal(data, v) //nolint:wrapcheck @@ -49,6 +50,7 @@ func Unmarshal(data []byte, v any) error { // Only supports parsing secrets from a *model.Secrets. func Marshal(v any) ([]byte, error) { m := make(map[string]string) + switch secrets := v.(type) { case *model.Secrets: for _, v := range *secrets { diff --git a/project/env/marshal_test.go b/project/env/marshal_test.go index 773e0b448..f98893dc3 100644 --- a/project/env/marshal_test.go +++ b/project/env/marshal_test.go @@ -54,6 +54,7 @@ func TestUnmarshal(t *testing.T) { t.Parallel() var secrets model.Secrets + err := env.Unmarshal(tc.data, &secrets) if err != nil { t.Fatalf("got error: %v", err) diff --git a/software/github.go b/software/github.go index 6a022c59e..d1b6d7657 100644 --- a/software/github.go +++ b/software/github.go @@ -16,6 +16,7 @@ func GetReleases(ctx context.Context) (Releases, error) { var releases Releases client := &http.Client{} //nolint:exhaustruct + req, err := http.NewRequestWithContext( ctx, http.MethodGet, @@ -34,7 +35,8 @@ func GetReleases(ctx context.Context) (Releases, error) { if resp.StatusCode != http.StatusOK { b, _ := io.ReadAll(resp.Body) - return nil, fmt.Errorf( //nolint:goerr113 + + return nil, fmt.Errorf( //nolint:err113 "failed to fetch releases with status code (%d): %s", resp.StatusCode, string(b), ) } diff --git a/software/sofware.go b/software/sofware.go index cf02276fc..267c52e63 100644 --- a/software/sofware.go +++ b/software/sofware.go @@ -46,7 +46,8 @@ func (mgr *Manager) GetReleases(ctx context.Context, version string) (Releases, if resp.StatusCode != http.StatusOK { b, _ := io.ReadAll(resp.Body) - return nil, fmt.Errorf( //nolint:goerr113 + + return nil, fmt.Errorf( //nolint:err113 "failed to fetch releases with status code (%d): %s", resp.StatusCode, string(b), ) } @@ -82,6 +83,7 @@ func (mgr *Manager) LatestRelease(ctx context.Context, version string) (Release, return Release{}, err } } + return mgr.cache[0], nil } @@ -125,17 +127,18 @@ func extractTarGz(gzipStream io.Reader, dst io.Writer) error { switch header.Typeflag { case tar.TypeDir: - return errors.New( //nolint:goerr113 + return errors.New( //nolint:err113 "expected a file inside tarball, found a directory instead", ) case tar.TypeReg: if _, err := io.Copy(dst, tarReader); err != nil { //nolint:gosec return fmt.Errorf("failed to copy file: %w", err) } + return nil default: - return fmt.Errorf( //nolint:goerr113 + return fmt.Errorf( //nolint:err113 "unknown type: %b in %s", header.Typeflag, header.Name, @@ -143,5 +146,5 @@ func extractTarGz(gzipStream io.Reader, dst io.Writer) error { } } - return errors.New("no file found in tarball") //nolint:goerr113 + return errors.New("no file found in tarball") //nolint:err113 } diff --git a/ssl/.ssl/local-fullchain.pem b/ssl/.ssl/local-fullchain.pem index 6e7afd720..a714894ab 100644 --- a/ssl/.ssl/local-fullchain.pem +++ b/ssl/.ssl/local-fullchain.pem @@ -1,27 +1,27 @@ -----BEGIN CERTIFICATE----- -MIIERDCCA8qgAwIBAgISBo3Iizk/T1buRlcsluT3QwdmMAoGCCqGSM49BAMDMDIx +MIIEQzCCA8mgAwIBAgISBndw2+I6pj0PHp0I3OLgwinHMAoGCCqGSM49BAMDMDIx CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQDEwJF -NjAeFw0yNTA3MDExMzQyMTdaFw0yNTA5MjkxMzQyMTZaMB8xHTAbBgNVBAMTFGxv -Y2FsLmF1dGgubmhvc3QucnVuMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfFpV -731uMXPTDISpaH3a6NmO9qji/mwn2GTSsJeXVyBq9dMTXD7hq0/JJE2NcaqinvBk -8xTJ/SxxN55/thBn9aOCAtEwggLNMA4GA1UdDwEB/wQEAwIHgDAdBgNVHSUEFjAU -BggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUl9FW -GnB73U9g01Ki2rF6q3Z03tQwHwYDVR0jBBgwFoAUkydGmAOpUWiOmNbEQkjbI79Y +NjAeFw0yNTA3MjkwNzUyMTlaFw0yNTEwMjcwNzUyMThaMB8xHTAbBgNVBAMTFGxv +Y2FsLmF1dGgubmhvc3QucnVuMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEz8lB +SSrSYsOs4gl1rQZN3l3oSkJkEhy/Af2T72uNeYo0+dRO98rcb6ovONkLjh+jzbOv +vlGzhJ72UFFpYXcM/KOCAtAwggLMMA4GA1UdDwEB/wQEAwIHgDAdBgNVHSUEFjAU +BggrBgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUWL3F +NCaF5830mq/GZfKitq8dHpowHwYDVR0jBBgwFoAUkydGmAOpUWiOmNbEQkjbI79Y lNIwMgYIKwYBBQUHAQEEJjAkMCIGCCsGAQUFBzAChhZodHRwOi8vZTYuaS5sZW5j ci5vcmcvMIHOBgNVHREEgcYwgcOCFGxvY2FsLmF1dGgubmhvc3QucnVughlsb2Nh bC5kYXNoYm9hcmQubmhvc3QucnVughJsb2NhbC5kYi5uaG9zdC5ydW6CGWxvY2Fs LmZ1bmN0aW9ucy5uaG9zdC5ydW6CF2xvY2FsLmdyYXBocWwubmhvc3QucnVughZs b2NhbC5oYXN1cmEubmhvc3QucnVughdsb2NhbC5tYWlsaG9nLm5ob3N0LnJ1boIX -bG9jYWwuc3RvcmFnZS5uaG9zdC5ydW4wEwYDVR0gBAwwCjAIBgZngQwBAgEwLgYD -VR0fBCcwJTAjoCGgH4YdaHR0cDovL2U2LmMubGVuY3Iub3JnLzEwMy5jcmwwggEC -BgorBgEEAdZ5AgQCBIHzBIHwAO4AdQB9WR4S4XgqexxhZ3xe/fjQh1wUoE6VnrkD -L9kOjC55uAAAAZfGbu3pAAAEAwBGMEQCIAannf7jUpxcwBGTQw24v1xkMVexRR47 -UF0EX/17CyqBAiAZjPns9l7dee7OHCBkA/7ZeEOQ5fqoK4hP/kbMBlpG6wB1ABLx -TjS9U3JMhAYZw48/ehP457Vih4icbTAFhOvlhiY6AAABl8Zu7e4AAAQDAEYwRAIg -PrznsYnXABwXpbsi2Cr35MvT7dxBSKxKanz2zP2r854CIFQkTlc+r/ccRRIoXn2t -6xpzgKFZG1x0dNtB3gNhx9WWMAoGCCqGSM49BAMDA2gAMGUCMHMbfpqxORJuKT1B -+R9xzmAy3RfuZnMODRZ9wcvrF72Ruby2xY9Izz3MKiJfKJaL0AIxAOjlLL33Hrug -y+F+hEgc8XKmiKjEVM0wTst/uUx+XocnfEz9/ZCrgnWPoqL19ttERA== +bG9jYWwuc3RvcmFnZS5uaG9zdC5ydW4wEwYDVR0gBAwwCjAIBgZngQwBAgEwLQYD +VR0fBCYwJDAioCCgHoYcaHR0cDovL2U2LmMubGVuY3Iub3JnLzcyLmNybDCCAQIG +CisGAQQB1nkCBAIEgfMEgfAA7gB0ABoE/0nQVB1Ar/agw7/x2MRnL07s7iNAaJhr +F0Au3Il9AAABmFVgliUAAAQDAEUwQwIfFvpaZRby+sC9Ie0G86ceDL5mwRzWZpfM +fCLEzWwNPgIgS0/BTGXmSRtT5ZP3tg13ZeWYHbZrg12aFxU3VU5ybloAdgAS8U40 +vVNyTIQGGcOPP3oT+Oe1YoeInG0wBYTr5YYmOgAAAZhVYJYTAAAEAwBHMEUCIQC6 +QwEDRPUPn9e3IVfNUD1nlEk+Onhl7kNtbQZ2ohbjCwIgTCQVP/YcgeLNLl48axF7 +UG0qBmU/gMb6T3Kn97/mhDkwCgYIKoZIzj0EAwMDaAAwZQIwakcXKxQj3+Pg4+dv +8V5p3yOr6atEHPfCTXH+U+Xkhmesp/IuUgzFxlrSAyTgDLOBAjEAnrE4GRvxhjqY +LcUcvF6uq18nq4XjUz3UUxlW/ldY2vxQ0DS2EE4wVmIVRlv/HWy/ -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIEVzCCAj+gAwIBAgIRALBXPpFzlydw27SHyzpFKzgwDQYJKoZIhvcNAQELBQAw diff --git a/ssl/.ssl/local-privkey.pem b/ssl/.ssl/local-privkey.pem index a2c9d3d94..1c06a09c4 100644 --- a/ssl/.ssl/local-privkey.pem +++ b/ssl/.ssl/local-privkey.pem @@ -1,5 +1,5 @@ -----BEGIN PRIVATE KEY----- -MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg7Gpw9N9KtTTpUHUF -4UBXrbOjwHfr90f6Ccv0g6FzM1ihRANCAAR8WlXvfW4xc9MMhKlofdro2Y72qOL+ -bCfYZNKwl5dXIGr10xNcPuGrT8kkTY1xqqKe8GTzFMn9LHE3nn+2EGf1 +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgubHeclCua1lKUFXc +d2Zb887kXuzCpjj6gwWFJFIklZ+hRANCAATPyUFJKtJiw6ziCXWtBk3eXehKQmQS +HL8B/ZPva415ijT51E73ytxvqi842QuOH6PNs6++UbOEnvZQUWlhdwz8 -----END PRIVATE KEY----- diff --git a/ssl/.ssl/sub-fullchain.pem b/ssl/.ssl/sub-fullchain.pem index 328ba5895..65ab8e4f3 100644 --- a/ssl/.ssl/sub-fullchain.pem +++ b/ssl/.ssl/sub-fullchain.pem @@ -1,52 +1,52 @@ -----BEGIN CERTIFICATE----- -MIIEVzCCA92gAwIBAgISBfMPhs972S/7gxp5Hzp3ptuKMAoGCCqGSM49BAMDMDIx +MIIEVjCCA92gAwIBAgISBiPBdzj4MllMHOJYsMFUBxMgMAoGCCqGSM49BAMDMDIx CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQDEwJF -NjAeFw0yNTA3MDExMzQzMzBaFw0yNTA5MjkxMzQzMjlaMCExHzAdBgNVBAMMFiou -YXV0aC5sb2NhbC5uaG9zdC5ydW4wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQ9 -p3e1CrInxVv+BuJCc4f/khLH3Is+VccbF5qM34vqj9p/WecEMX/BfV79SHKS6uiQ -+KCZVr3dwygj6hzk1L2vo4IC4jCCAt4wDgYDVR0PAQH/BAQDAgeAMB0GA1UdJQQW -MBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQR -IBLvCCom/WVK4kCZ/py8apnxljAfBgNVHSMEGDAWgBSTJ0aYA6lRaI6Y1sRCSNsj -v1iU0jAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAKGFmh0dHA6Ly9lNi5pLmxl +NTAeFw0yNTA3MjkwNzU0MDRaFw0yNTEwMjcwNzU0MDNaMCExHzAdBgNVBAMMFiou +YXV0aC5sb2NhbC5uaG9zdC5ydW4wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARR +05GrBaskCEYNbYMpaYPeHwICir5loizwTYsJ99B+Yly1tsXSbceMp/yKCDVWn5Z+ +R01JrO2oJ9djDRIN0gi3o4IC4jCCAt4wDgYDVR0PAQH/BAQDAgeAMB0GA1UdJQQW +MBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBSJ +WZpY1ZCWhLEtDfHTZkRY6iBXozAfBgNVHSMEGDAWgBSfK1/PPCFPnQS37SssxMZw +i9LXDTAyBggrBgEFBQcBAQQmMCQwIgYIKwYBBQUHMAKGFmh0dHA6Ly9lNS5pLmxl bmNyLm9yZy8wgd4GA1UdEQSB1jCB04IWKi5hdXRoLmxvY2FsLm5ob3N0LnJ1boIb Ki5kYXNoYm9hcmQubG9jYWwubmhvc3QucnVughQqLmRiLmxvY2FsLm5ob3N0LnJ1 boIbKi5mdW5jdGlvbnMubG9jYWwubmhvc3QucnVughkqLmdyYXBocWwubG9jYWwu bmhvc3QucnVughgqLmhhc3VyYS5sb2NhbC5uaG9zdC5ydW6CGSoubWFpbGhvZy5s b2NhbC5uaG9zdC5ydW6CGSouc3RvcmFnZS5sb2NhbC5uaG9zdC5ydW4wEwYDVR0g -BAwwCjAIBgZngQwBAgEwLQYDVR0fBCYwJDAioCCgHoYcaHR0cDovL2U2LmMubGVu -Y3Iub3JnLzExLmNybDCCAQQGCisGAQQB1nkCBAIEgfUEgfIA8AB2ABLxTjS9U3JM -hAYZw48/ehP457Vih4icbTAFhOvlhiY6AAABl8ZwCE4AAAQDAEcwRQIgcs0uu7Ft -okxmG+fOtx7LUSuk6ihO1UT9RaDmGsM1URwCIQDEzhEb8SQuvbFPyjQYPAP+oYrz -TnGKqAITNerZ8QrmUgB2AMz7D2qFcQll/pWbU87psnwi6YVcDZeNtql+VMD+TA2w -AAABl8ZwCPUAAAQDAEcwRQIgU9hl2WlXR2P45h7lUMZ8ld8HaWf6kWB/HIZYcL5f -W2wCIQCE4wUJxBpJfKnI+MWvjKkif1+N8Wn8jMhDw62YlBa6qjAKBggqhkjOPQQD -AwNoADBlAjAR1dy/1Mg8no3Xn40OYvsupCCkZJ+nLXF0pBdtPmpGDUH24RbP5RGP -UncBJ3/jzu0CMQDixqflveQaZO0xHbwy4iGDhX0O0WhMW9DsDLMXFbh+cBvlzJFc -BBmM2/PCNnR6VeY= +BAwwCjAIBgZngQwBAgEwLQYDVR0fBCYwJDAioCCgHoYcaHR0cDovL2U1LmMubGVu +Y3Iub3JnLzMzLmNybDCCAQQGCisGAQQB1nkCBAIEgfUEgfIA8AB2AMz7D2qFcQll +/pWbU87psnwi6YVcDZeNtql+VMD+TA2wAAABmFViLtQAAAQDAEcwRQIgY9lg02Gc +TrnxvpdOaIrjBTrGSyqpJSSL01zCW9Ht4T0CIQD3mhWCu4ujHKoJYh9UhtOJPdA7 +XZguU/8D+ecX/XmZjQB2ABoE/0nQVB1Ar/agw7/x2MRnL07s7iNAaJhrF0Au3Il9 +AAABmFViLuAAAAQDAEcwRQIhAKv3VChl/rFsWj7Qw5o79SWRO0wAP02HzwA3Qusr +hNkMAiAK/NzdBjhtjY45twQ/vdndnwUxFzgbvus14NHqt2bCWjAKBggqhkjOPQQD +AwNnADBkAjAgNjnoFBix5zOMihKQfwOSnvbEvLl9Pb/5LO886TQAhYaid/8MZXqj +Ps+mXg7NGzICMBjh8XeIVWrFLCJSb0gUIdViwj+CH6MednDVsyskCb0gN/8fqbme +IJZ4m2x0SngcZA== -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- -MIIEVzCCAj+gAwIBAgIRALBXPpFzlydw27SHyzpFKzgwDQYJKoZIhvcNAQELBQAw +MIIEVzCCAj+gAwIBAgIRAIOPbGPOsTmMYgZigxXJ/d4wDQYJKoZIhvcNAQELBQAw TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMjQwMzEzMDAwMDAw WhcNMjcwMzEyMjM1OTU5WjAyMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg -RW5jcnlwdDELMAkGA1UEAxMCRTYwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATZ8Z5G -h/ghcWCoJuuj+rnq2h25EqfUJtlRFLFhfHWWvyILOR/VvtEKRqotPEoJhC6+QJVV -6RlAN2Z17TJOdwRJ+HB7wxjnzvdxEP6sdNgA1O1tHHMWMxCcOrLqbGL0vbijgfgw +RW5jcnlwdDELMAkGA1UEAxMCRTUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQNCzqK +a2GOtu/cX1jnxkJFVKtj9mZhSAouWXW0gQI3ULc/FnncmOyhKJdyIBwsz9V8UiBO +VHhbhBRrwJCuhezAUUE8Wod/Bk3U/mDR+mwt4X2VEIiiCFQPmRpM5uoKrNijgfgw gfUwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcD -ATASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBSTJ0aYA6lRaI6Y1sRCSNsj -v1iU0jAfBgNVHSMEGDAWgBR5tFnme7bl5AFzgAiIyBpY9umbbjAyBggrBgEFBQcB +ATASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBSfK1/PPCFPnQS37SssxMZw +i9LXDTAfBgNVHSMEGDAWgBR5tFnme7bl5AFzgAiIyBpY9umbbjAyBggrBgEFBQcB AQQmMCQwIgYIKwYBBQUHMAKGFmh0dHA6Ly94MS5pLmxlbmNyLm9yZy8wEwYDVR0g BAwwCjAIBgZngQwBAgEwJwYDVR0fBCAwHjAcoBqgGIYWaHR0cDovL3gxLmMubGVu -Y3Iub3JnLzANBgkqhkiG9w0BAQsFAAOCAgEAfYt7SiA1sgWGCIpunk46r4AExIRc -MxkKgUhNlrrv1B21hOaXN/5miE+LOTbrcmU/M9yvC6MVY730GNFoL8IhJ8j8vrOL -pMY22OP6baS1k9YMrtDTlwJHoGby04ThTUeBDksS9RiuHvicZqBedQdIF65pZuhp -eDcGBcLiYasQr/EO5gxxtLyTmgsHSOVSBcFOn9lgv7LECPq9i7mfH3mpxgrRKSxH -pOoZ0KXMcB+hHuvlklHntvcI0mMMQ0mhYj6qtMFStkF1RpCG3IPdIwpVCQqu8GV7 -s8ubknRzs+3C/Bm19RFOoiPpDkwvyNfvmQ14XkyqqKK5oZ8zhD32kFRQkxa8uZSu -h4aTImFxknu39waBxIRXE4jKxlAmQc4QjFZoq1KmQqQg0J/1JF8RlFvJas1VcjLv -YlvUB2t6npO6oQjB3l+PNf0DpQH7iUx3Wz5AjQCi6L25FjyE06q6BZ/QlmtYdl/8 -ZYao4SRqPEs/6cAiF+Qf5zg2UkaWtDphl1LKMuTNLotvsX99HP69V2faNyegodQ0 -LyTApr/vT01YPE46vNsDLgK+4cL6TrzC/a4WcmF5SRJ938zrv/duJHLXQIku5v0+ -EwOy59Hdm0PT/Er/84dDV0CSjdR/2XuZM3kpysSKLgD1cKiDA+IRguODCxfO9cyY -Ig46v9mFmBvyH04= +Y3Iub3JnLzANBgkqhkiG9w0BAQsFAAOCAgEAH3KdNEVCQdqk0LKyuNImTKdRJY1C +2uw2SJajuhqkyGPY8C+zzsufZ+mgnhnq1A2KVQOSykOEnUbx1cy637rBAihx97r+ +bcwbZM6sTDIaEriR/PLk6LKs9Be0uoVxgOKDcpG9svD33J+G9Lcfv1K9luDmSTgG +6XNFIN5vfI5gs/lMPyojEMdIzK9blcl2/1vKxO8WGCcjvsQ1nJ/Pwt8LQZBfOFyV +XP8ubAp/au3dc4EKWG9MO5zcx1qT9+NXRGdVWxGvmBFRAajciMfXME1ZuGmk3/GO +koAM7ZkjZmleyokP1LGzmfJcUd9s7eeu1/9/eg5XlXd/55GtYjAM+C4DG5i7eaNq +cm2F+yxYIPt6cbbtYVNJCGfHWqHEQ4FYStUyFnv8sjyqU8ypgZaNJ9aVcWSICLOI +E1/Qv/7oKsnZCWJ926wU6RqG1OYPGOi1zuABhLw61cuPVDT28nQS/e6z95cJXq0e +K1BcaJ6fJZsmbjRgD5p3mvEf5vdQM7MCEvU0tHbsx2I5mHHJoABHb8KVBgWp/lcX +GWiWaeOyB7RP+OfDtvi2OsapxXiV7vNVs7fMlrRjY1joKaqmmycnBvAq14AEbtyL +sVfOS66B8apkeFX2NY4XPEYV4ZSCe8VHPrdrERk2wILG3T/EGmSIkCYVUMSnjmJd +VQD9F6Na/+zmXCc= -----END CERTIFICATE----- diff --git a/ssl/.ssl/sub-privkey.pem b/ssl/.ssl/sub-privkey.pem index 87a0bdd12..10544531a 100644 --- a/ssl/.ssl/sub-privkey.pem +++ b/ssl/.ssl/sub-privkey.pem @@ -1,5 +1,5 @@ -----BEGIN PRIVATE KEY----- -MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgXwQpGuXsRYykU2lV -SsBOzMvp0CU8sYlppH4wm7o0/R6hRANCAAQ9p3e1CrInxVv+BuJCc4f/khLH3Is+ -VccbF5qM34vqj9p/WecEMX/BfV79SHKS6uiQ+KCZVr3dwygj6hzk1L2v +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgZATWogZ6tmL5MjpX +6A6/oXqxKOFkd3UADVNUpqdLKZyhRANCAARR05GrBaskCEYNbYMpaYPeHwICir5l +oizwTYsJ99B+Yly1tsXSbceMp/yKCDVWn5Z+R01JrO2oJ9djDRIN0gi3 -----END PRIVATE KEY----- diff --git a/vendor/github.com/99designs/gqlgen/graphql/executable_schema.go b/vendor/github.com/99designs/gqlgen/graphql/executable_schema.go index 89d64dc56..4870e4fc8 100644 --- a/vendor/github.com/99designs/gqlgen/graphql/executable_schema.go +++ b/vendor/github.com/99designs/gqlgen/graphql/executable_schema.go @@ -38,24 +38,14 @@ func collectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies f.Selections = append(f.Selections, sel.SelectionSet...) case *ast.InlineFragment: - // To allow simplified "collect all" types behavior, pass an empty list - // of types that the type condition must satisfy: we will apply the - // fragment regardless of type condition. - // - // When the type condition is not set (... { field }) we will apply the - // fragment to any satisfying types. - // - // We will only NOT apply the fragment when we have at least one type in - // the list we must satisfy and a type condition to compare them to. - if len(satisfies) > 0 && sel.TypeCondition != "" && !instanceOf(sel.TypeCondition, satisfies) { + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { continue } - - if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + if !doesFragmentConditionMatch(sel.TypeCondition, satisfies) { continue } - shouldDefer, label := deferrable(sel.Directives, reqCtx.Variables) + shouldDefer, label := deferrable(sel.Directives, reqCtx.Variables) for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) { f := getOrCreateAndAppendField( &groupedFields, childField.Name, childField.Alias, childField.ObjectDefinition, @@ -73,6 +63,9 @@ func collectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies if _, seen := visited[fragmentName]; seen { continue } + if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { + continue + } visited[fragmentName] = true fragment := reqCtx.Doc.Fragments.ForName(fragmentName) @@ -80,16 +73,11 @@ func collectFields(reqCtx *OperationContext, selSet ast.SelectionSet, satisfies // should never happen, validator has already run panic(fmt.Errorf("missing fragment %s", fragmentName)) } - - if len(satisfies) > 0 && !instanceOf(fragment.TypeCondition, satisfies) { + if !doesFragmentConditionMatch(fragment.TypeCondition, satisfies) { continue } - if !shouldIncludeNode(sel.Directives, reqCtx.Variables) { - continue - } shouldDefer, label := deferrable(sel.Directives, reqCtx.Variables) - for _, childField := range collectFields(reqCtx, fragment.SelectionSet, satisfies, visited) { f := getOrCreateAndAppendField(&groupedFields, childField.Name, childField.Alias, childField.ObjectDefinition, @@ -115,9 +103,24 @@ type CollectedField struct { Deferrable *Deferrable } -func instanceOf(val string, satisfies []string) bool { - for _, s := range satisfies { - if val == s { +func doesFragmentConditionMatch(typeCondition string, satisfies []string) bool { + // To allow simplified "collect all" types behavior, pass an empty list of types + // that the type condition must satisfy: we will apply the fragment regardless of + // type condition. + if len(satisfies) == 0 { + return true + } + + // When the type condition is not set (... { field }) we will apply the fragment + // to any satisfying types. + if typeCondition == "" { + return true + } + + // To handle abstract types we pass in a list of all known types that the current + // type will satisfy. + for _, satisfyingType := range satisfies { + if typeCondition == satisfyingType { return true } } diff --git a/vendor/github.com/99designs/gqlgen/graphql/executor/executor.go b/vendor/github.com/99designs/gqlgen/graphql/executor/executor.go index 2ea71e0ed..95302f914 100644 --- a/vendor/github.com/99designs/gqlgen/graphql/executor/executor.go +++ b/vendor/github.com/99designs/gqlgen/graphql/executor/executor.go @@ -216,23 +216,30 @@ func (e *Executor) parseQuery( stats.Validation.Start = graphql.Now() - if len(doc.Operations) == 0 { + if doc == nil || len(doc.Operations) == 0 { err = gqlerror.Errorf("no operation provided") gqlErr, _ := err.(*gqlerror.Error) errcode.Set(err, errcode.ValidationFailed) return nil, gqlerror.List{gqlErr} } + currentRules := rules.NewDefaultRules() + + // Customise rules as required + // TODO(steve): consider currentRules.RemoveRule(rules.MaxIntrospectionDepth.Name) + // swap out the FieldsOnCorrectType rule with one that doesn't provide suggestions if e.disableSuggestion { - validator.RemoveRule("FieldsOnCorrectType") - + currentRules.RemoveRule("FieldsOnCorrectType") rule := rules.FieldsOnCorrectTypeRuleWithoutSuggestions - // rule may already have been added - validator.ReplaceRule(rule.Name, rule.RuleFunc) + currentRules.AddRule(rule.Name, rule.RuleFunc) + } else { // or vice versa + currentRules.RemoveRule("FieldsOnCorrectTypeWithoutSuggestions") + rule := rules.FieldsOnCorrectTypeRule + currentRules.AddRule(rule.Name, rule.RuleFunc) } - listErr := validator.Validate(e.es.Schema(), doc) + listErr := validator.ValidateWithRules(e.es.Schema(), doc, currentRules) if len(listErr) != 0 { for _, e := range listErr { errcode.Set(e, errcode.ValidationFailed) diff --git a/vendor/github.com/99designs/gqlgen/graphql/fieldset.go b/vendor/github.com/99designs/gqlgen/graphql/fieldset.go index 2c9e3dc93..73c048dc3 100644 --- a/vendor/github.com/99designs/gqlgen/graphql/fieldset.go +++ b/vendor/github.com/99designs/gqlgen/graphql/fieldset.go @@ -58,13 +58,18 @@ func (m *FieldSet) Dispatch(ctx context.Context) { func (m *FieldSet) MarshalGQL(writer io.Writer) { writer.Write(openBrace) + writtenFields := make(map[string]bool, len(m.fields)) for i, field := range m.fields { + if writtenFields[field.Alias] { + continue + } if i != 0 { writer.Write(comma) } writeQuotedString(writer, field.Alias) writer.Write(colon) m.Values[i].MarshalGQL(writer) + writtenFields[field.Alias] = true } writer.Write(closeBrace) } diff --git a/vendor/github.com/99designs/gqlgen/graphql/handler/transport/headers.go b/vendor/github.com/99designs/gqlgen/graphql/handler/transport/headers.go index d0b3a0ac0..c792575f8 100644 --- a/vendor/github.com/99designs/gqlgen/graphql/handler/transport/headers.go +++ b/vendor/github.com/99designs/gqlgen/graphql/handler/transport/headers.go @@ -11,7 +11,7 @@ const ( acceptApplicationGraphqlResponseJson = "application/graphql-response+json" ) -func determineResponseContentType(explicitHeaders map[string][]string, r *http.Request) string { +func determineResponseContentType(explicitHeaders map[string][]string, r *http.Request, useGrapQLResponseJsonByDefault bool) string { for k, v := range explicitHeaders { if strings.EqualFold(k, "Content-Type") { return v[0] @@ -19,9 +19,10 @@ func determineResponseContentType(explicitHeaders map[string][]string, r *http.R } accept := r.Header.Get("Accept") - // TODO(steve): Consider adding config option to opt-in to - // default "application/graphql-response+json" if accept == "" { + if useGrapQLResponseJsonByDefault { + return acceptApplicationGraphqlResponseJson + } return acceptApplicationJson } @@ -32,7 +33,10 @@ func determineResponseContentType(explicitHeaders map[string][]string, r *http.R } switch mediaType { case "*/*", "application/*": - return acceptApplicationGraphqlResponseJson + if useGrapQLResponseJsonByDefault { + return acceptApplicationGraphqlResponseJson + } + return acceptApplicationJson case "application/json": return acceptApplicationJson case "application/graphql-response+json": diff --git a/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_get.go b/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_get.go index a3cffcc7b..26f8a681d 100644 --- a/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_get.go +++ b/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_get.go @@ -20,6 +20,9 @@ type GET struct { // Map of all headers that are added to graphql response. If not // set, only one header: Content-Type: application/graphql-response+json will be set. ResponseHeaders map[string][]string + // UseGrapQLResponseJsonByDefault determines whether to use 'application/graphql-response+json' as the response content type + // when the Accept header is empty or 'application/*' or '*/*'. + UseGrapQLResponseJsonByDefault bool } var _ graphql.Transport = GET{} @@ -39,7 +42,7 @@ func (h GET) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecut writeJsonError(w, err.Error()) return } - contentType := determineResponseContentType(h.ResponseHeaders, r) + contentType := determineResponseContentType(h.ResponseHeaders, r, h.UseGrapQLResponseJsonByDefault) responseHeaders := mergeHeaders( map[string][]string{ "Content-Type": {contentType}, diff --git a/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_post.go b/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_post.go index 34076b897..d57bf3c4a 100644 --- a/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_post.go +++ b/vendor/github.com/99designs/gqlgen/graphql/handler/transport/http_post.go @@ -19,6 +19,10 @@ type POST struct { // Map of all headers that are added to graphql response. If not // set, only one header: Content-Type: application/graphql-response+json will be set. ResponseHeaders map[string][]string + + // UseGrapQLResponseJsonByDefault determines whether to use 'application/graphql-response+json' as the response content type + // when the Accept header is empty or 'application/*' or '*/*'. + UseGrapQLResponseJsonByDefault bool } var _ graphql.Transport = POST{} @@ -55,7 +59,7 @@ var pool = sync.Pool{ func (h POST) Do(w http.ResponseWriter, r *http.Request, exec graphql.GraphExecutor) { ctx := r.Context() - contentType := determineResponseContentType(h.ResponseHeaders, r) + contentType := determineResponseContentType(h.ResponseHeaders, r, h.UseGrapQLResponseJsonByDefault) responseHeaders := mergeHeaders( map[string][]string{ "Content-Type": {contentType}, diff --git a/vendor/github.com/99designs/gqlgen/graphql/version.go b/vendor/github.com/99designs/gqlgen/graphql/version.go index 821a51261..590013780 100644 --- a/vendor/github.com/99designs/gqlgen/graphql/version.go +++ b/vendor/github.com/99designs/gqlgen/graphql/version.go @@ -1,3 +1,3 @@ package graphql -const Version = "v0.17.73" +const Version = "v0.17.76" diff --git a/vendor/github.com/go-viper/mapstructure/v2/.editorconfig b/vendor/github.com/go-viper/mapstructure/v2/.editorconfig index 1f664d13a..faef0c91e 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/.editorconfig +++ b/vendor/github.com/go-viper/mapstructure/v2/.editorconfig @@ -16,3 +16,6 @@ indent_style = tab [*.nix] indent_size = 2 + +[.golangci.yaml] +indent_size = 2 diff --git a/vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml b/vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml index 763143aa7..ec1680b3a 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml +++ b/vendor/github.com/go-viper/mapstructure/v2/.golangci.yaml @@ -1,23 +1,39 @@ -run: - timeout: 5m +version: "2" -linters-settings: - gci: - sections: - - standard - - default - - prefix(github.com/go-viper/mapstructure) - golint: - min-confidence: 0 - goimports: - local-prefixes: github.com/go-viper/maptstructure +run: + timeout: 10m linters: - disable-all: true + enable: + - govet + - ineffassign + # - misspell + - nolintlint + # - revive + + disable: + - errcheck + - staticcheck + - unused + + settings: + misspell: + locale: US + nolintlint: + allow-unused: false # report any unused nolint directives + require-specific: false # don't require nolint directives to be specific about which linter is being skipped + +formatters: enable: - gci - gofmt - gofumpt - goimports - - staticcheck - # - stylecheck + # - golines + + settings: + gci: + sections: + - standard + - default + - localmodule diff --git a/vendor/github.com/go-viper/mapstructure/v2/README.md b/vendor/github.com/go-viper/mapstructure/v2/README.md index dd5ec69dd..bc4be08e6 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/README.md +++ b/vendor/github.com/go-viper/mapstructure/v2/README.md @@ -1,8 +1,9 @@ # mapstructure -[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/go-viper/mapstructure/ci.yaml?branch=main&style=flat-square)](https://github.com/go-viper/mapstructure/actions?query=workflow%3ACI) -[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/mod/github.com/go-viper/mapstructure/v2) -![Go Version](https://img.shields.io/badge/go%20version-%3E=1.18-61CFDD.svg?style=flat-square) +[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/go-viper/mapstructure/ci.yaml?style=flat-square)](https://github.com/go-viper/mapstructure/actions/workflows/ci.yaml) +[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/mod/github.com/go-viper/mapstructure) +![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/go-viper/mapstructure?style=flat-square&color=61CFDD) +[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/go-viper/mapstructure/badge?style=flat-square)](https://deps.dev/go/github.com%252Fgo-viper%252Fmapstructure%252Fv2) mapstructure is a Go library for decoding generic map values to structures and vice versa, while providing helpful error handling. @@ -29,7 +30,7 @@ The API is the same, so you don't need to change anything else. Here is a script that can help you with the migration: ```shell -sed -i 's/github.com\/mitchellh\/mapstructure/github.com\/go-viper\/mapstructure\/v2/g' $(find . -type f -name '*.go') +sed -i 's|github.com/mitchellh/mapstructure|github.com/go-viper/mapstructure/v2|g' $(find . -type f -name '*.go') ``` If you need more time to migrate your code, that is absolutely fine. diff --git a/vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go b/vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go index 1f3c69d4b..57c6de69d 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go +++ b/vendor/github.com/go-viper/mapstructure/v2/decode_hooks.go @@ -100,7 +100,11 @@ func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc { if err != nil { return nil, err } - newFrom = reflect.ValueOf(data) + if v, ok := data.(reflect.Value); ok { + newFrom = v + } else { + newFrom = reflect.ValueOf(data) + } } return data, nil @@ -386,6 +390,26 @@ func StringToNetIPAddrPortHookFunc() DecodeHookFunc { } } +// StringToNetIPPrefixHookFunc returns a DecodeHookFunc that converts +// strings to netip.Prefix. +func StringToNetIPPrefixHookFunc() DecodeHookFunc { + return func( + f reflect.Type, + t reflect.Type, + data interface{}, + ) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + if t != reflect.TypeOf(netip.Prefix{}) { + return data, nil + } + + // Convert it by parsing + return netip.ParsePrefix(data.(string)) + } +} + // StringToBasicTypeHookFunc returns a DecodeHookFunc that converts // strings to basic types. // int8, uint8, int16, uint16, int32, uint32, int64, uint64, int, uint, float32, float64, bool, byte, rune, complex64, complex128 diff --git a/vendor/github.com/go-viper/mapstructure/v2/errors.go b/vendor/github.com/go-viper/mapstructure/v2/errors.go new file mode 100644 index 000000000..31a3edfb0 --- /dev/null +++ b/vendor/github.com/go-viper/mapstructure/v2/errors.go @@ -0,0 +1,74 @@ +package mapstructure + +import ( + "fmt" + "reflect" +) + +// Error interface is implemented by all errors emitted by mapstructure. +// +// Use [errors.As] to check if an error implements this interface. +type Error interface { + error + + mapstructure() +} + +// DecodeError is a generic error type that holds information about +// a decoding error together with the name of the field that caused the error. +type DecodeError struct { + name string + err error +} + +func newDecodeError(name string, err error) *DecodeError { + return &DecodeError{ + name: name, + err: err, + } +} + +func (e *DecodeError) Name() string { + return e.name +} + +func (e *DecodeError) Unwrap() error { + return e.err +} + +func (e *DecodeError) Error() string { + return fmt.Sprintf("'%s' %s", e.name, e.err) +} + +func (*DecodeError) mapstructure() {} + +// ParseError is an error type that indicates a value could not be parsed +// into the expected type. +type ParseError struct { + Expected reflect.Value + Value any + Err error +} + +func (e *ParseError) Error() string { + return fmt.Sprintf("cannot parse value as '%s': %s", e.Expected.Type(), e.Err) +} + +func (*ParseError) mapstructure() {} + +// UnconvertibleTypeError is an error type that indicates a value could not be +// converted to the expected type. +type UnconvertibleTypeError struct { + Expected reflect.Value + Value any +} + +func (e *UnconvertibleTypeError) Error() string { + return fmt.Sprintf( + "expected type '%s', got unconvertible type '%s'", + e.Expected.Type(), + reflect.TypeOf(e.Value), + ) +} + +func (*UnconvertibleTypeError) mapstructure() {} diff --git a/vendor/github.com/go-viper/mapstructure/v2/flake.lock b/vendor/github.com/go-viper/mapstructure/v2/flake.lock index 4bea8154e..5e67bdd6b 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/flake.lock +++ b/vendor/github.com/go-viper/mapstructure/v2/flake.lock @@ -2,30 +2,28 @@ "nodes": { "cachix": { "inputs": { - "devenv": "devenv_2", + "devenv": [ + "devenv" + ], "flake-compat": [ - "devenv", - "flake-compat" + "devenv" ], - "nixpkgs": [ - "devenv", - "nixpkgs" + "git-hooks": [ + "devenv" ], - "pre-commit-hooks": [ - "devenv", - "pre-commit-hooks" - ] + "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1712055811, - "narHash": "sha256-7FcfMm5A/f02yyzuavJe06zLa9hcMHsagE28ADcmQvk=", + "lastModified": 1742042642, + "narHash": "sha256-D0gP8srrX0qj+wNYNPdtVJsQuFzIng3q43thnHXQ/es=", "owner": "cachix", "repo": "cachix", - "rev": "02e38da89851ec7fec3356a5c04bc8349cae0e30", + "rev": "a624d3eaf4b1d225f918de8543ed739f2f574203", "type": "github" }, "original": { "owner": "cachix", + "ref": "latest", "repo": "cachix", "type": "github" } @@ -33,52 +31,21 @@ "devenv": { "inputs": { "cachix": "cachix", - "flake-compat": "flake-compat_2", - "nix": "nix_2", - "nixpkgs": "nixpkgs_2", - "pre-commit-hooks": "pre-commit-hooks" - }, - "locked": { - "lastModified": 1717245169, - "narHash": "sha256-+mW3rTBjGU8p1THJN0lX/Dd/8FbnF+3dB+mJuSaxewE=", - "owner": "cachix", - "repo": "devenv", - "rev": "c3f9f053c077c6f88a3de5276d9178c62baa3fc3", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "devenv", - "type": "github" - } - }, - "devenv_2": { - "inputs": { - "flake-compat": [ - "devenv", - "cachix", - "flake-compat" - ], + "flake-compat": "flake-compat", + "git-hooks": "git-hooks", "nix": "nix", - "nixpkgs": "nixpkgs", - "poetry2nix": "poetry2nix", - "pre-commit-hooks": [ - "devenv", - "cachix", - "pre-commit-hooks" - ] + "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1708704632, - "narHash": "sha256-w+dOIW60FKMaHI1q5714CSibk99JfYxm0CzTinYWr+Q=", + "lastModified": 1744876578, + "narHash": "sha256-8MTBj2REB8t29sIBLpxbR0+AEGJ7f+RkzZPAGsFd40c=", "owner": "cachix", "repo": "devenv", - "rev": "2ee4450b0f4b95a1b90f2eb5ffea98b90e48c196", + "rev": "7ff7c351bba20d0615be25ecdcbcf79b57b85fe1", "type": "github" }, "original": { "owner": "cachix", - "ref": "python-rewrite", "repo": "devenv", "type": "github" } @@ -86,27 +53,11 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "type": "github" }, "original": { @@ -117,14 +68,18 @@ }, "flake-parts": { "inputs": { - "nixpkgs-lib": "nixpkgs-lib" + "nixpkgs-lib": [ + "devenv", + "nix", + "nixpkgs" + ] }, "locked": { - "lastModified": 1717285511, - "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", "type": "github" }, "original": { @@ -133,39 +88,46 @@ "type": "github" } }, - "flake-utils": { + "flake-parts_2": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, - "flake-utils_2": { + "git-hooks": { "inputs": { - "systems": "systems_2" + "flake-compat": [ + "devenv" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ] }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "lastModified": 1742649964, + "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "cachix", + "repo": "git-hooks.nix", "type": "github" } }, @@ -173,7 +135,7 @@ "inputs": { "nixpkgs": [ "devenv", - "pre-commit-hooks", + "git-hooks", "nixpkgs" ] }, @@ -191,166 +153,109 @@ "type": "github" } }, - "nix": { - "inputs": { - "flake-compat": "flake-compat", - "nixpkgs": [ - "devenv", - "cachix", - "devenv", - "nixpkgs" - ], - "nixpkgs-regression": "nixpkgs-regression" - }, - "locked": { - "lastModified": 1712911606, - "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", - "owner": "domenkozar", - "repo": "nix", - "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", - "type": "github" - }, - "original": { - "owner": "domenkozar", - "ref": "devenv-2.21", - "repo": "nix", - "type": "github" - } - }, - "nix-github-actions": { - "inputs": { - "nixpkgs": [ - "devenv", - "cachix", - "devenv", - "poetry2nix", - "nixpkgs" - ] - }, + "libgit2": { + "flake": false, "locked": { - "lastModified": 1688870561, - "narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=", - "owner": "nix-community", - "repo": "nix-github-actions", - "rev": "165b1650b753316aa7f1787f3005a8d2da0f5301", + "lastModified": 1697646580, + "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", + "owner": "libgit2", + "repo": "libgit2", + "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", "type": "github" }, "original": { - "owner": "nix-community", - "repo": "nix-github-actions", + "owner": "libgit2", + "repo": "libgit2", "type": "github" } }, - "nix_2": { + "nix": { "inputs": { "flake-compat": [ - "devenv", - "flake-compat" + "devenv" ], - "nixpkgs": [ - "devenv", - "nixpkgs" + "flake-parts": "flake-parts", + "libgit2": "libgit2", + "nixpkgs": "nixpkgs_2", + "nixpkgs-23-11": [ + "devenv" + ], + "nixpkgs-regression": [ + "devenv" ], - "nixpkgs-regression": "nixpkgs-regression_2" + "pre-commit-hooks": [ + "devenv" + ] }, "locked": { - "lastModified": 1712911606, - "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "lastModified": 1741798497, + "narHash": "sha256-E3j+3MoY8Y96mG1dUIiLFm2tZmNbRvSiyN7CrSKuAVg=", "owner": "domenkozar", "repo": "nix", - "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "rev": "f3f44b2baaf6c4c6e179de8cbb1cc6db031083cd", "type": "github" }, "original": { "owner": "domenkozar", - "ref": "devenv-2.21", + "ref": "devenv-2.24", "repo": "nix", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1692808169, - "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", + "lastModified": 1733212471, + "narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", + "rev": "55d15ad12a74eb7d4646254e13638ad0c4128776", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs-lib": { "locked": { - "lastModified": 1717284937, - "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" - } - }, - "nixpkgs-regression": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - } - }, - "nixpkgs-regression_2": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "lastModified": 1743296961, + "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa", "type": "github" }, "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "owner": "nix-community", + "repo": "nixpkgs.lib", "type": "github" } }, - "nixpkgs-stable": { + "nixpkgs_2": { "locked": { - "lastModified": 1710695816, - "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "lastModified": 1717432640, + "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "release-24.05", "repo": "nixpkgs", "type": "github" } }, - "nixpkgs_2": { + "nixpkgs_3": { "locked": { - "lastModified": 1713361204, - "narHash": "sha256-TA6EDunWTkc5FvDCqU3W2T3SFn0gRZqh6D/hJnM02MM=", + "lastModified": 1733477122, + "narHash": "sha256-qamMCz5mNpQmgBwc8SB5tVMlD5sbwVIToVZtSxMph9s=", "owner": "cachix", "repo": "devenv-nixpkgs", - "rev": "285676e87ad9f0ca23d8714a6ab61e7e027020c6", + "rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857", "type": "github" }, "original": { @@ -360,13 +265,13 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { - "lastModified": 1717112898, - "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", "type": "github" }, "original": { @@ -376,94 +281,11 @@ "type": "github" } }, - "poetry2nix": { - "inputs": { - "flake-utils": "flake-utils", - "nix-github-actions": "nix-github-actions", - "nixpkgs": [ - "devenv", - "cachix", - "devenv", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1692876271, - "narHash": "sha256-IXfZEkI0Mal5y1jr6IRWMqK8GW2/f28xJenZIPQqkY0=", - "owner": "nix-community", - "repo": "poetry2nix", - "rev": "d5006be9c2c2417dafb2e2e5034d83fabd207ee3", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "poetry2nix", - "type": "github" - } - }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": [ - "devenv", - "flake-compat" - ], - "flake-utils": "flake-utils_2", - "gitignore": "gitignore", - "nixpkgs": [ - "devenv", - "nixpkgs" - ], - "nixpkgs-stable": "nixpkgs-stable" - }, - "locked": { - "lastModified": 1713775815, - "narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { "devenv": "devenv", - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_3" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs_4" } } }, diff --git a/vendor/github.com/go-viper/mapstructure/v2/flake.nix b/vendor/github.com/go-viper/mapstructure/v2/flake.nix index 4ed0f5331..3b116f426 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/flake.nix +++ b/vendor/github.com/go-viper/mapstructure/v2/flake.nix @@ -5,35 +5,42 @@ devenv.url = "github:cachix/devenv"; }; - outputs = inputs@{ flake-parts, ... }: + outputs = + inputs@{ flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { imports = [ inputs.devenv.flakeModule ]; - systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; + systems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; - perSystem = { config, self', inputs', pkgs, system, ... }: rec { - devenv.shells = { - default = { - languages = { - go.enable = true; - }; + perSystem = + { pkgs, ... }: + rec { + devenv.shells = { + default = { + languages = { + go.enable = true; + }; - pre-commit.hooks = { - nixpkgs-fmt.enable = true; - }; + pre-commit.hooks = { + nixpkgs-fmt.enable = true; + }; - packages = with pkgs; [ - golangci-lint - ]; + packages = with pkgs; [ + golangci-lint + ]; - # https://github.com/cachix/devenv/issues/528#issuecomment-1556108767 - containers = pkgs.lib.mkForce { }; - }; + # https://github.com/cachix/devenv/issues/528#issuecomment-1556108767 + containers = pkgs.lib.mkForce { }; + }; - ci = devenv.shells.default; + ci = devenv.shells.default; + }; }; - }; }; } diff --git a/vendor/github.com/go-viper/mapstructure/v2/mapstructure.go b/vendor/github.com/go-viper/mapstructure/v2/mapstructure.go index e77e63ba3..4b738a3a9 100644 --- a/vendor/github.com/go-viper/mapstructure/v2/mapstructure.go +++ b/vendor/github.com/go-viper/mapstructure/v2/mapstructure.go @@ -115,15 +115,36 @@ // // When decoding from a struct to any other value, you may use the // ",omitempty" suffix on your tag to omit that value if it equates to -// the zero value. The zero value of all types is specified in the Go -// specification. +// the zero value, or a zero-length element. The zero value of all types is +// specified in the Go specification. // // For example, the zero type of a numeric type is zero ("0"). If the struct // field value is zero and a numeric type, the field is empty, and it won't -// be encoded into the destination type. +// be encoded into the destination type. And likewise for the URLs field, if the +// slice is nil or empty, it won't be encoded into the destination type. // // type Source struct { -// Age int `mapstructure:",omitempty"` +// Age int `mapstructure:",omitempty"` +// URLs []string `mapstructure:",omitempty"` +// } +// +// # Omit Zero Values +// +// When decoding from a struct to any other value, you may use the +// ",omitzero" suffix on your tag to omit that value if it equates to the zero +// value. The zero value of all types is specified in the Go specification. +// +// For example, the zero type of a numeric type is zero ("0"). If the struct +// field value is zero and a numeric type, the field is empty, and it won't +// be encoded into the destination type. And likewise for the URLs field, if the +// slice is nil, it won't be encoded into the destination type. +// +// Note that if the field is a slice, and it is empty but not nil, it will +// still be encoded into the destination type. +// +// type Source struct { +// Age int `mapstructure:",omitzero"` +// URLs []string `mapstructure:",omitzero"` // } // // # Unexported fields @@ -222,6 +243,12 @@ type DecoderConfig struct { // will affect all nested structs as well. ErrorUnset bool + // AllowUnsetPointer, if set to true, will prevent fields with pointer types + // from being reported as unset, even if ErrorUnset is true and the field was + // not present in the input data. This allows pointer fields to be optional + // without triggering an error when they are missing. + AllowUnsetPointer bool + // ZeroFields, if set to true, will zero fields before writing them. // For example, a map will be emptied before decoded values are put in // it. If this is false, a map will be merged. @@ -504,7 +531,7 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e var err error input, err = d.cachedDecodeHook(inputVal, outVal) if err != nil { - return fmt.Errorf("error decoding '%s': %w", name, err) + return newDecodeError(name, err) } } if isNil(input) { @@ -542,7 +569,7 @@ func (d *Decoder) decode(name string, input interface{}, outVal reflect.Value) e err = d.decodeFunc(name, input, outVal) default: // If we reached this point then we weren't able to decode it - return fmt.Errorf("%s: unsupported type: %s", name, outputKind) + return newDecodeError(name, fmt.Errorf("unsupported type: %s", outputKind)) } // If we reached here, then we successfully decoded SOMETHING, so @@ -603,9 +630,10 @@ func (d *Decoder) decodeBasic(name string, data interface{}, val reflect.Value) dataValType := dataVal.Type() if !dataValType.AssignableTo(val.Type()) { - return fmt.Errorf( - "'%s' expected type '%s', got '%s'", - name, val.Type(), dataValType) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } val.Set(dataVal) @@ -656,9 +684,10 @@ func (d *Decoder) decodeString(name string, data interface{}, val reflect.Value) } if !converted { - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } return nil @@ -692,20 +721,28 @@ func (d *Decoder) decodeInt(name string, data interface{}, val reflect.Value) er if err == nil { val.SetInt(i) } else { - return fmt.Errorf("cannot parse '%s' as int: %s", name, err) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: err, + }) } case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": jn := data.(json.Number) i, err := jn.Int64() if err != nil { - return fmt.Errorf( - "error decoding json.Number into %s: %s", name, err) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: err, + }) } val.SetInt(i) default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } return nil @@ -720,8 +757,11 @@ func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) e case dataKind == reflect.Int: i := dataVal.Int() if i < 0 && !d.config.WeaklyTypedInput { - return fmt.Errorf("cannot parse '%s', %d overflows uint", - name, i) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: fmt.Errorf("%d overflows uint", i), + }) } val.SetUint(uint64(i)) case dataKind == reflect.Uint: @@ -729,8 +769,11 @@ func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) e case dataKind == reflect.Float32: f := dataVal.Float() if f < 0 && !d.config.WeaklyTypedInput { - return fmt.Errorf("cannot parse '%s', %f overflows uint", - name, f) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: fmt.Errorf("%f overflows uint", f), + }) } val.SetUint(uint64(f)) case dataKind == reflect.Bool && d.config.WeaklyTypedInput: @@ -749,20 +792,28 @@ func (d *Decoder) decodeUint(name string, data interface{}, val reflect.Value) e if err == nil { val.SetUint(i) } else { - return fmt.Errorf("cannot parse '%s' as uint: %s", name, err) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: err, + }) } case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": jn := data.(json.Number) i, err := strconv.ParseUint(string(jn), 0, 64) if err != nil { - return fmt.Errorf( - "error decoding json.Number into %s: %s", name, err) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: err, + }) } val.SetUint(i) default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } return nil @@ -788,12 +839,17 @@ func (d *Decoder) decodeBool(name string, data interface{}, val reflect.Value) e } else if dataVal.String() == "" { val.SetBool(false) } else { - return fmt.Errorf("cannot parse '%s' as bool: %s", name, err) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: err, + }) } default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%#v', value: '%#v'", - name, val, dataVal, data) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } return nil @@ -827,20 +883,28 @@ func (d *Decoder) decodeFloat(name string, data interface{}, val reflect.Value) if err == nil { val.SetFloat(f) } else { - return fmt.Errorf("cannot parse '%s' as float: %s", name, err) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: err, + }) } case dataType.PkgPath() == "encoding/json" && dataType.Name() == "Number": jn := data.(json.Number) i, err := jn.Float64() if err != nil { - return fmt.Errorf( - "error decoding json.Number into %s: %s", name, err) + return newDecodeError(name, &ParseError{ + Expected: val, + Value: data, + Err: err, + }) } val.SetFloat(i) default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } return nil @@ -854,9 +918,10 @@ func (d *Decoder) decodeComplex(name string, data interface{}, val reflect.Value case dataKind == reflect.Complex64: val.SetComplex(dataVal.Complex()) default: - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } return nil @@ -900,7 +965,10 @@ func (d *Decoder) decodeMap(name string, data interface{}, val reflect.Value) er fallthrough default: - return fmt.Errorf("'%s' expected a map, got '%s'", name, dataVal.Kind()) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } } @@ -986,7 +1054,10 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re // to the map value. v := dataVal.Field(i) if !v.Type().AssignableTo(valMap.Type().Elem()) { - return fmt.Errorf("cannot assign type '%s' to map value field of type '%s'", v.Type(), valMap.Type().Elem()) + return newDecodeError( + name+"."+f.Name, + fmt.Errorf("cannot assign type %q to map value field of type %q", v.Type(), valMap.Type().Elem()), + ) } tagValue := f.Tag.Get(d.config.TagName) @@ -1011,6 +1082,11 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re continue } + // If "omitzero" is specified in the tag, it ignores zero values. + if strings.Index(tagValue[index+1:], "omitzero") != -1 && v.IsZero() { + continue + } + // If "squash" is specified in the tag, we squash the field down. squash = squash || strings.Contains(tagValue[index+1:], d.config.SquashTagOption) if squash { @@ -1021,12 +1097,18 @@ func (d *Decoder) decodeMapFromStruct(name string, dataVal reflect.Value, val re // The final type must be a struct if v.Kind() != reflect.Struct { - return fmt.Errorf("cannot squash non-struct type '%s'", v.Type()) + return newDecodeError( + name+"."+f.Name, + fmt.Errorf("cannot squash non-struct type %q", v.Type()), + ) } } else { if strings.Index(tagValue[index+1:], "remain") != -1 { if v.Kind() != reflect.Map { - return fmt.Errorf("error remain-tag field with invalid type: '%s'", v.Type()) + return newDecodeError( + name+"."+f.Name, + fmt.Errorf("error remain-tag field with invalid type: %q", v.Type()), + ) } ptr := v.MapRange() @@ -1146,9 +1228,10 @@ func (d *Decoder) decodeFunc(name string, data interface{}, val reflect.Value) e // into that. Then set the value of the pointer to this type. dataVal := reflect.Indirect(reflect.ValueOf(data)) if val.Type() != dataVal.Type() { - return fmt.Errorf( - "'%s' expected type '%s', got unconvertible type '%s', value: '%v'", - name, val.Type(), dataVal.Type(), data) + return newDecodeError(name, &UnconvertibleTypeError{ + Expected: val, + Value: data, + }) } val.Set(dataVal) return nil @@ -1189,8 +1272,8 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) } } - return fmt.Errorf( - "'%s': source data must be an array or slice, got %s", name, dataValKind) + return newDecodeError(name, + fmt.Errorf("source data must be an array or slice, got %s", dataValKind)) } // If the input value is nil, then don't allocate since empty != nil @@ -1257,13 +1340,13 @@ func (d *Decoder) decodeArray(name string, data interface{}, val reflect.Value) } } - return fmt.Errorf( - "'%s': source data must be an array or slice, got %s", name, dataValKind) + return newDecodeError(name, + fmt.Errorf("source data must be an array or slice, got %s", dataValKind)) } if dataVal.Len() > arrayType.Len() { - return fmt.Errorf( - "'%s': expected source data to have length less or equal to %d, got %d", name, arrayType.Len(), dataVal.Len()) + return newDecodeError(name, + fmt.Errorf("expected source data to have length less or equal to %d, got %d", arrayType.Len(), dataVal.Len())) } // Make a new array to hold our result, same size as the original data. @@ -1328,16 +1411,16 @@ func (d *Decoder) decodeStruct(name string, data interface{}, val reflect.Value) return result default: - return fmt.Errorf("'%s' expected a map, got '%s'", name, dataVal.Kind()) + return newDecodeError(name, + fmt.Errorf("expected a map or struct, got %q", dataValKind)) } } func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) error { dataValType := dataVal.Type() if kind := dataValType.Key().Kind(); kind != reflect.String && kind != reflect.Interface { - return fmt.Errorf( - "'%s' needs a map with string keys, has '%s' keys", - name, dataValType.Key().Kind()) + return newDecodeError(name, + fmt.Errorf("needs a map with string keys, has %q keys", kind)) } dataValKeys := make(map[reflect.Value]struct{}) @@ -1410,7 +1493,10 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e structs = append(structs, fieldVal.Elem().Elem()) } default: - errs = append(errs, fmt.Errorf("%s: unsupported type for squash: %s", fieldType.Name, fieldVal.Kind())) + errs = append(errs, newDecodeError( + name+"."+fieldType.Name, + fmt.Errorf("unsupported type for squash: %s", fieldVal.Kind()), + )) } continue } @@ -1461,7 +1547,9 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e if !rawMapVal.IsValid() { // There was no matching key in the map for the value in // the struct. Remember it for potential errors and metadata. - targetValKeysUnused[fieldName] = struct{}{} + if !(d.config.AllowUnsetPointer && fieldValue.Kind() == reflect.Ptr) { + targetValKeysUnused[fieldName] = struct{}{} + } continue } } @@ -1517,8 +1605,10 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } sort.Strings(keys) - err := fmt.Errorf("'%s' has invalid keys: %s", name, strings.Join(keys, ", ")) - errs = append(errs, err) + errs = append(errs, newDecodeError( + name, + fmt.Errorf("has invalid keys: %s", strings.Join(keys, ", ")), + )) } if d.config.ErrorUnset && len(targetValKeysUnused) > 0 { @@ -1528,8 +1618,10 @@ func (d *Decoder) decodeStructFromMap(name string, dataVal, val reflect.Value) e } sort.Strings(keys) - err := fmt.Errorf("'%s' has unset fields: %s", name, strings.Join(keys, ", ")) - errs = append(errs, err) + errs = append(errs, newDecodeError( + name, + fmt.Errorf("has unset fields: %s", strings.Join(keys, ", ")), + )) } if err := errors.Join(errs...); err != nil { diff --git a/vendor/github.com/nhost/be/lib/graphql/VERSION b/vendor/github.com/nhost/be/lib/graphql/VERSION deleted file mode 100644 index cb676de10..000000000 --- a/vendor/github.com/nhost/be/lib/graphql/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.0-dev diff --git a/vendor/github.com/nhost/be/lib/graphql/context/gin.go b/vendor/github.com/nhost/be/lib/graphql/context/gin.go index f69c9a8b7..514ca0b24 100644 --- a/vendor/github.com/nhost/be/lib/graphql/context/gin.go +++ b/vendor/github.com/nhost/be/lib/graphql/context/gin.go @@ -35,15 +35,16 @@ func GinContextToContext(ctx context.Context, ginCtx *gin.Context) context.Conte func GinContextFromContext(ctx context.Context) (*gin.Context, error) { ginContext := ctx.Value(ginContextKey) if ginContext == nil { - err := errors.New("could not retrieve gin.Context") //nolint: goerr113 + err := errors.New("could not retrieve gin.Context") //nolint: err113 return nil, err } gc, ok := ginContext.(*gin.Context) if !ok { - err := errors.New("gin.Context has wrong type") //nolint: goerr113 + err := errors.New("gin.Context has wrong type") //nolint: err113 return nil, err } + return gc, nil } @@ -55,6 +56,7 @@ func HTTPHeaderFromGinContext(ctx context.Context) (http.Header, error) { if !ok { return nil, ErrWrongTypeHTTPHeader } + return headers, nil } diff --git a/vendor/github.com/nhost/be/lib/graphql/context/logger.go b/vendor/github.com/nhost/be/lib/graphql/context/logger.go index ce810e38f..475c2ee20 100644 --- a/vendor/github.com/nhost/be/lib/graphql/context/logger.go +++ b/vendor/github.com/nhost/be/lib/graphql/context/logger.go @@ -19,5 +19,6 @@ func LoggerFromContext(ctx context.Context) *logrus.Entry { if !ok { return logrus.NewEntry(logrus.New()) } + return logger } diff --git a/vendor/github.com/nhost/be/lib/graphql/handler/handler.go b/vendor/github.com/nhost/be/lib/graphql/handler/handler.go index d02f8efb7..30e210740 100644 --- a/vendor/github.com/nhost/be/lib/graphql/handler/handler.go +++ b/vendor/github.com/nhost/be/lib/graphql/handler/handler.go @@ -20,6 +20,7 @@ func Healthz(f func() error) gin.HandlerFunc { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } + c.JSON(http.StatusOK, gin.H{ "healthz": "ok", }) diff --git a/vendor/github.com/nhost/be/lib/graphql/middleware/accounting.go b/vendor/github.com/nhost/be/lib/graphql/middleware/accounting.go index 878b36c38..e55a9d7e5 100644 --- a/vendor/github.com/nhost/be/lib/graphql/middleware/accounting.go +++ b/vendor/github.com/nhost/be/lib/graphql/middleware/accounting.go @@ -21,6 +21,7 @@ func GraphqlAccounting(c *gin.Context) { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{ "message": "failed to read request body", }) + return } diff --git a/vendor/github.com/nhost/be/lib/graphql/middleware/logger.go b/vendor/github.com/nhost/be/lib/graphql/middleware/logger.go index 6460de846..7f94caf1e 100644 --- a/vendor/github.com/nhost/be/lib/graphql/middleware/logger.go +++ b/vendor/github.com/nhost/be/lib/graphql/middleware/logger.go @@ -15,6 +15,7 @@ func Logger(logger logrus.FieldLogger) gin.HandlerFunc { startTime := time.Now() trace, _ := nhtracing.FromContext(ctx.Request.Context()) + traceID := trace.TraceID if traceID == "" { traceID = uuid.New().String() diff --git a/vendor/github.com/nhost/be/lib/graphql/middleware/prometheus.go b/vendor/github.com/nhost/be/lib/graphql/middleware/prometheus.go index bda3ad2e2..0585383f5 100644 --- a/vendor/github.com/nhost/be/lib/graphql/middleware/prometheus.go +++ b/vendor/github.com/nhost/be/lib/graphql/middleware/prometheus.go @@ -10,8 +10,10 @@ import ( ) func PrometheusGraphqlAroundFieldsInstrumentation() graphql.FieldMiddleware { - const success = "success" - const failure = "failure" + const ( + success = "success" + failure = "failure" + ) requestsStarted := promauto.NewCounterVec( prometheus.CounterOpts{ //nolint: exhaustruct @@ -48,10 +50,12 @@ func PrometheusGraphqlAroundFieldsInstrumentation() graphql.FieldMiddleware { requestsStarted.WithLabelValues(operationType, rootField).Inc() res, err := next(ctx) + status := success if err != nil { status = failure } + requestsCompletedCounter.WithLabelValues(operationType, rootField, status).Inc() timeToHandleActionHistogram.WithLabelValues(operationType, rootField, status). diff --git a/vendor/github.com/nhost/be/lib/graphql/middleware/session_variables.go b/vendor/github.com/nhost/be/lib/graphql/middleware/session_variables.go index 1a5ccfe23..9c1c6a110 100644 --- a/vendor/github.com/nhost/be/lib/graphql/middleware/session_variables.go +++ b/vendor/github.com/nhost/be/lib/graphql/middleware/session_variables.go @@ -66,6 +66,7 @@ func ParseJWTFunc(jwtSecret JWTSecret) func(tokenString string) (*jwt.Token, err if err != nil { return nil, fmt.Errorf("error parsing token: %w", err) } + return token, nil } } @@ -76,10 +77,12 @@ func SessionVariablesToCtx(ctx context.Context, session *SessionVariables) conte func SessionVariablesFromCtx(ctx context.Context) *SessionVariables { s := ctx.Value(sessionVariablesToCtx{}) + session, ok := s.(*SessionVariables) if !ok { return nil } + return session } @@ -105,6 +108,7 @@ func SessionVariablesReader( c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{ "message": "unauthorized", }) + return } @@ -209,6 +213,7 @@ func getSessionVariablesFromAccessToken( //nolint:cyclop,funlen } accessToken := strings.TrimPrefix(headers.Get(headerAuthorization), "Bearer ") + token, err := jwtParser(accessToken) if err != nil { logger.WithError(err).Error("error parsing jwt") diff --git a/vendor/github.com/nhost/be/lib/graphql/project.nix b/vendor/github.com/nhost/be/lib/graphql/project.nix index 862e73231..b253125f5 100644 --- a/vendor/github.com/nhost/be/lib/graphql/project.nix +++ b/vendor/github.com/nhost/be/lib/graphql/project.nix @@ -3,7 +3,8 @@ let name = "graphql"; submodule = "lib/${name}"; description = "Common graphql functionality"; - version = pkgs.lib.fileContents ./VERSION; + version = "0.0.0-dev"; + created = "1970-01-01T00:00:00Z"; # source files needed for the build src = nix-filter.lib.filter { diff --git a/vendor/github.com/nhost/be/services/mimir/graph/data.go b/vendor/github.com/nhost/be/services/mimir/graph/data.go index 2db68d8c3..40b3a99bd 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/data.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/data.go @@ -15,10 +15,12 @@ func (d Data) IndexApp(id string) (int, error) { if app == nil { continue } + if app.AppID == id { return i, nil } } + return 0, ErrAppNotFound } @@ -33,6 +35,7 @@ func (s Services) Clone() Services { resolvedConfig: v.resolvedConfig.Clone(), } } + return newServices } @@ -76,6 +79,7 @@ func (a *App) IndexSecret(name string) (int, error) { return i, nil } } + return 0, ErrSecretNotFound } @@ -85,6 +89,7 @@ func (a *App) IndexService(id string) (int, error) { return i, nil } } + return 0, ErrServiceNotFound } @@ -111,5 +116,6 @@ func (a *App) ResolveSystemConfig(sch *schema.Schema) (*model.ConfigSystemConfig if err != nil { return nil, fmt.Errorf("failed to fill system config: %w", err) } + return cfg, nil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/generated/generated.go b/vendor/github.com/nhost/be/services/mimir/graph/generated/generated.go index ef61777f3..94bc94ffe 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/generated/generated.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/generated/generated.go @@ -285,8 +285,9 @@ type ComplexityRoot struct { } ConfigAuthsessionaccessTokenCustomClaims struct { - Key func(childComplexity int) int - Value func(childComplexity int) int + Default func(childComplexity int) int + Key func(childComplexity int) int + Value func(childComplexity int) int } ConfigAutoscaler struct { @@ -544,6 +545,7 @@ type ComplexityRoot struct { MinWalSize func(childComplexity int) int RandomPageCost func(childComplexity int) int SharedBuffers func(childComplexity int) int + TrackIoTiming func(childComplexity int) int WalBuffers func(childComplexity int) int WalLevel func(childComplexity int) int WorkMem func(childComplexity int) int @@ -1609,6 +1611,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.ConfigAuthUserRoles.Default(childComplexity), true + case "ConfigAuthsessionaccessTokenCustomClaims.default": + if e.complexity.ConfigAuthsessionaccessTokenCustomClaims.Default == nil { + break + } + + return e.complexity.ConfigAuthsessionaccessTokenCustomClaims.Default(childComplexity), true + case "ConfigAuthsessionaccessTokenCustomClaims.key": if e.complexity.ConfigAuthsessionaccessTokenCustomClaims.Key == nil { break @@ -2645,6 +2654,13 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.complexity.ConfigPostgresSettings.SharedBuffers(childComplexity), true + case "ConfigPostgresSettings.trackIoTiming": + if e.complexity.ConfigPostgresSettings.TrackIoTiming == nil { + break + } + + return e.complexity.ConfigPostgresSettings.TrackIoTiming(childComplexity), true + case "ConfigPostgresSettings.walBuffers": if e.complexity.ConfigPostgresSettings.WalBuffers == nil { break @@ -5541,16 +5557,22 @@ type ConfigAuthsessionaccessTokenCustomClaims { """ value: String! + """ + + """ + default: String } input ConfigAuthsessionaccessTokenCustomClaimsUpdateInput { key: String value: String + default: String } input ConfigAuthsessionaccessTokenCustomClaimsInsertInput { key: String! value: String! + default: String } input ConfigAuthsessionaccessTokenCustomClaimsComparisonExp { @@ -5559,6 +5581,7 @@ input ConfigAuthsessionaccessTokenCustomClaimsComparisonExp { _or: [ConfigAuthsessionaccessTokenCustomClaimsComparisonExp!] key: ConfigStringComparisonExp value: ConfigStringComparisonExp + default: ConfigStringComparisonExp } """ @@ -7191,6 +7214,10 @@ type ConfigPostgresSettings { """ archiveTimeout: ConfigInt32 + """ + + """ + trackIoTiming: String } input ConfigPostgresSettingsUpdateInput { @@ -7216,6 +7243,7 @@ input ConfigPostgresSettingsUpdateInput { maxWalSenders: ConfigInt32 maxReplicationSlots: ConfigInt32 archiveTimeout: ConfigInt32 + trackIoTiming: String } input ConfigPostgresSettingsInsertInput { @@ -7241,6 +7269,7 @@ input ConfigPostgresSettingsInsertInput { maxWalSenders: ConfigInt32 maxReplicationSlots: ConfigInt32 archiveTimeout: ConfigInt32 + trackIoTiming: String } input ConfigPostgresSettingsComparisonExp { @@ -7269,6 +7298,7 @@ input ConfigPostgresSettingsComparisonExp { maxWalSenders: ConfigInt32ComparisonExp maxReplicationSlots: ConfigInt32ComparisonExp archiveTimeout: ConfigInt32ComparisonExp + trackIoTiming: ConfigStringComparisonExp } """ @@ -14537,6 +14567,8 @@ func (ec *executionContext) fieldContext_ConfigAuthSessionAccessToken_customClai return ec.fieldContext_ConfigAuthsessionaccessTokenCustomClaims_key(ctx, field) case "value": return ec.fieldContext_ConfigAuthsessionaccessTokenCustomClaims_value(ctx, field) + case "default": + return ec.fieldContext_ConfigAuthsessionaccessTokenCustomClaims_default(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ConfigAuthsessionaccessTokenCustomClaims", field.Name) }, @@ -15614,6 +15646,47 @@ func (ec *executionContext) fieldContext_ConfigAuthsessionaccessTokenCustomClaim return fc, nil } +func (ec *executionContext) _ConfigAuthsessionaccessTokenCustomClaims_default(ctx context.Context, field graphql.CollectedField, obj *model.ConfigAuthsessionaccessTokenCustomClaims) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConfigAuthsessionaccessTokenCustomClaims_default(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.Default, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ConfigAuthsessionaccessTokenCustomClaims_default(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConfigAuthsessionaccessTokenCustomClaims", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _ConfigAutoscaler_maxReplicas(ctx context.Context, field graphql.CollectedField, obj *model.ConfigAutoscaler) (ret graphql.Marshaler) { fc, err := ec.fieldContext_ConfigAutoscaler_maxReplicas(ctx, field) if err != nil { @@ -21099,6 +21172,8 @@ func (ec *executionContext) fieldContext_ConfigPostgres_settings(_ context.Conte return ec.fieldContext_ConfigPostgresSettings_maxReplicationSlots(ctx, field) case "archiveTimeout": return ec.fieldContext_ConfigPostgresSettings_archiveTimeout(ctx, field) + case "trackIoTiming": + return ec.fieldContext_ConfigPostgresSettings_trackIoTiming(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type ConfigPostgresSettings", field.Name) }, @@ -22315,6 +22390,47 @@ func (ec *executionContext) fieldContext_ConfigPostgresSettings_archiveTimeout(_ return fc, nil } +func (ec *executionContext) _ConfigPostgresSettings_trackIoTiming(ctx context.Context, field graphql.CollectedField, obj *model.ConfigPostgresSettings) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ConfigPostgresSettings_trackIoTiming(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (any, error) { + ctx = rctx // use context from middleware stack in children + return obj.TrackIoTiming, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ConfigPostgresSettings_trackIoTiming(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ConfigPostgresSettings", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _ConfigProvider_smtp(ctx context.Context, field graphql.CollectedField, obj *model.ConfigProvider) (ret graphql.Marshaler) { fc, err := ec.fieldContext_ConfigProvider_smtp(ctx, field) if err != nil { @@ -33373,7 +33489,7 @@ func (ec *executionContext) unmarshalInputConfigAuthsessionaccessTokenCustomClai asMap[k] = v } - fieldsInOrder := [...]string{"_and", "_not", "_or", "key", "value"} + fieldsInOrder := [...]string{"_and", "_not", "_or", "key", "value", "default"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -33415,6 +33531,13 @@ func (ec *executionContext) unmarshalInputConfigAuthsessionaccessTokenCustomClai return it, err } it.Value = data + case "default": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default")) + data, err := ec.unmarshalOConfigStringComparisonExp2ᚖgithubᚗcomᚋnhostᚋbeᚋservicesᚋmimirᚋmodelᚐGenericComparisonExp(ctx, v) + if err != nil { + return it, err + } + it.Default = data } } @@ -33428,7 +33551,7 @@ func (ec *executionContext) unmarshalInputConfigAuthsessionaccessTokenCustomClai asMap[k] = v } - fieldsInOrder := [...]string{"key", "value"} + fieldsInOrder := [...]string{"key", "value", "default"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -33449,6 +33572,13 @@ func (ec *executionContext) unmarshalInputConfigAuthsessionaccessTokenCustomClai return it, err } it.Value = data + case "default": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("default")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Default = data } } @@ -37861,7 +37991,7 @@ func (ec *executionContext) unmarshalInputConfigPostgresSettingsComparisonExp(ct asMap[k] = v } - fieldsInOrder := [...]string{"_and", "_not", "_or", "jit", "maxConnections", "sharedBuffers", "effectiveCacheSize", "maintenanceWorkMem", "checkpointCompletionTarget", "walBuffers", "defaultStatisticsTarget", "randomPageCost", "effectiveIOConcurrency", "workMem", "hugePages", "minWalSize", "maxWalSize", "maxWorkerProcesses", "maxParallelWorkersPerGather", "maxParallelWorkers", "maxParallelMaintenanceWorkers", "walLevel", "maxWalSenders", "maxReplicationSlots", "archiveTimeout"} + fieldsInOrder := [...]string{"_and", "_not", "_or", "jit", "maxConnections", "sharedBuffers", "effectiveCacheSize", "maintenanceWorkMem", "checkpointCompletionTarget", "walBuffers", "defaultStatisticsTarget", "randomPageCost", "effectiveIOConcurrency", "workMem", "hugePages", "minWalSize", "maxWalSize", "maxWorkerProcesses", "maxParallelWorkersPerGather", "maxParallelWorkers", "maxParallelMaintenanceWorkers", "walLevel", "maxWalSenders", "maxReplicationSlots", "archiveTimeout", "trackIoTiming"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -38043,6 +38173,13 @@ func (ec *executionContext) unmarshalInputConfigPostgresSettingsComparisonExp(ct return it, err } it.ArchiveTimeout = data + case "trackIoTiming": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trackIoTiming")) + data, err := ec.unmarshalOConfigStringComparisonExp2ᚖgithubᚗcomᚋnhostᚋbeᚋservicesᚋmimirᚋmodelᚐGenericComparisonExp(ctx, v) + if err != nil { + return it, err + } + it.TrackIoTiming = data } } @@ -38056,7 +38193,7 @@ func (ec *executionContext) unmarshalInputConfigPostgresSettingsInsertInput(ctx asMap[k] = v } - fieldsInOrder := [...]string{"jit", "maxConnections", "sharedBuffers", "effectiveCacheSize", "maintenanceWorkMem", "checkpointCompletionTarget", "walBuffers", "defaultStatisticsTarget", "randomPageCost", "effectiveIOConcurrency", "workMem", "hugePages", "minWalSize", "maxWalSize", "maxWorkerProcesses", "maxParallelWorkersPerGather", "maxParallelWorkers", "maxParallelMaintenanceWorkers", "walLevel", "maxWalSenders", "maxReplicationSlots", "archiveTimeout"} + fieldsInOrder := [...]string{"jit", "maxConnections", "sharedBuffers", "effectiveCacheSize", "maintenanceWorkMem", "checkpointCompletionTarget", "walBuffers", "defaultStatisticsTarget", "randomPageCost", "effectiveIOConcurrency", "workMem", "hugePages", "minWalSize", "maxWalSize", "maxWorkerProcesses", "maxParallelWorkersPerGather", "maxParallelWorkers", "maxParallelMaintenanceWorkers", "walLevel", "maxWalSenders", "maxReplicationSlots", "archiveTimeout", "trackIoTiming"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -38217,6 +38354,13 @@ func (ec *executionContext) unmarshalInputConfigPostgresSettingsInsertInput(ctx return it, err } it.ArchiveTimeout = data + case "trackIoTiming": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("trackIoTiming")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.TrackIoTiming = data } } @@ -42721,6 +42865,8 @@ func (ec *executionContext) _ConfigAuthsessionaccessTokenCustomClaims(ctx contex if out.Values[i] == graphql.Null { out.Invalids++ } + case "default": + out.Values[i] = ec._ConfigAuthsessionaccessTokenCustomClaims_default(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -44433,6 +44579,8 @@ func (ec *executionContext) _ConfigPostgresSettings(ctx context.Context, sel ast out.Values[i] = ec._ConfigPostgresSettings_maxReplicationSlots(ctx, field, obj) case "archiveTimeout": out.Values[i] = ec._ConfigPostgresSettings_archiveTimeout(ctx, field, obj) + case "trackIoTiming": + out.Values[i] = ec._ConfigPostgresSettings_trackIoTiming(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -46322,6 +46470,7 @@ func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v any) ( } func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + _ = sel res := graphql.MarshalBoolean(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -46772,6 +46921,7 @@ func (ec *executionContext) unmarshalNConfigEmail2string(ctx context.Context, v } func (ec *executionContext) marshalNConfigEmail2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47071,6 +47221,7 @@ func (ec *executionContext) unmarshalNConfigHasuraAPIs2string(ctx context.Contex } func (ec *executionContext) marshalNConfigHasuraAPIs2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47166,6 +47317,7 @@ func (ec *executionContext) unmarshalNConfigInt162int16(ctx context.Context, v a } func (ec *executionContext) marshalNConfigInt162int16(ctx context.Context, sel ast.SelectionSet, v int16) graphql.Marshaler { + _ = sel res := types.MarshalInt16(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47181,6 +47333,7 @@ func (ec *executionContext) unmarshalNConfigInt322int32(ctx context.Context, v a } func (ec *executionContext) marshalNConfigInt322int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { + _ = sel res := graphql.MarshalInt32(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47196,6 +47349,7 @@ func (ec *executionContext) unmarshalNConfigInt642int64(ctx context.Context, v a } func (ec *executionContext) marshalNConfigInt642int64(ctx context.Context, sel ast.SelectionSet, v int64) graphql.Marshaler { + _ = sel res := graphql.MarshalInt64(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47211,6 +47365,7 @@ func (ec *executionContext) unmarshalNConfigInt82int8(ctx context.Context, v any } func (ec *executionContext) marshalNConfigInt82int8(ctx context.Context, sel ast.SelectionSet, v int8) graphql.Marshaler { + _ = sel res := types.MarshalInt8(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47252,6 +47407,7 @@ func (ec *executionContext) unmarshalNConfigLocale2string(ctx context.Context, v } func (ec *executionContext) marshalNConfigLocale2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47292,6 +47448,7 @@ func (ec *executionContext) unmarshalNConfigPort2uint16(ctx context.Context, v a } func (ec *executionContext) marshalNConfigPort2uint16(ctx context.Context, sel ast.SelectionSet, v uint16) graphql.Marshaler { + _ = sel res := types.MarshalUint16(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47501,6 +47658,7 @@ func (ec *executionContext) unmarshalNConfigRunServiceName2string(ctx context.Co } func (ec *executionContext) marshalNConfigRunServiceName2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47713,6 +47871,7 @@ func (ec *executionContext) unmarshalNConfigUint162uint16(ctx context.Context, v } func (ec *executionContext) marshalNConfigUint162uint16(ctx context.Context, sel ast.SelectionSet, v uint16) graphql.Marshaler { + _ = sel res := types.MarshalUint16(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47728,6 +47887,7 @@ func (ec *executionContext) unmarshalNConfigUint2uint(ctx context.Context, v any } func (ec *executionContext) marshalNConfigUint2uint(ctx context.Context, sel ast.SelectionSet, v uint) graphql.Marshaler { + _ = sel res := graphql.MarshalUint(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47743,6 +47903,7 @@ func (ec *executionContext) unmarshalNConfigUint322uint32(ctx context.Context, v } func (ec *executionContext) marshalNConfigUint322uint32(ctx context.Context, sel ast.SelectionSet, v uint32) graphql.Marshaler { + _ = sel res := graphql.MarshalUint32(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47758,6 +47919,7 @@ func (ec *executionContext) unmarshalNConfigUint642uint64(ctx context.Context, v } func (ec *executionContext) marshalNConfigUint642uint64(ctx context.Context, sel ast.SelectionSet, v uint64) graphql.Marshaler { + _ = sel res := graphql.MarshalUint64(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47773,6 +47935,7 @@ func (ec *executionContext) unmarshalNConfigUint82uint8(ctx context.Context, v a } func (ec *executionContext) marshalNConfigUint82uint8(ctx context.Context, sel ast.SelectionSet, v uint8) graphql.Marshaler { + _ = sel res := types.MarshalUint8(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47788,6 +47951,7 @@ func (ec *executionContext) unmarshalNConfigUrl2string(ctx context.Context, v an } func (ec *executionContext) marshalNConfigUrl2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47803,6 +47967,7 @@ func (ec *executionContext) unmarshalNConfigUserRole2string(ctx context.Context, } func (ec *executionContext) marshalNConfigUserRole2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47818,6 +47983,7 @@ func (ec *executionContext) unmarshalNFloat2float64(ctx context.Context, v any) } func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.SelectionSet, v float64) graphql.Marshaler { + _ = sel res := graphql.MarshalFloatContext(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47847,6 +48013,7 @@ func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v any) (int, } func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler { + _ = sel res := graphql.MarshalInt(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47862,6 +48029,7 @@ func (ec *executionContext) unmarshalNString2string(ctx context.Context, v any) } func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -47955,6 +48123,7 @@ func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Con } func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -48143,6 +48312,7 @@ func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v a } func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -48158,6 +48328,7 @@ func (ec *executionContext) unmarshalNuuid2string(ctx context.Context, v any) (s } func (ec *executionContext) marshalNuuid2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + _ = sel res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -48173,6 +48344,8 @@ func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v any) ( } func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + _ = sel + _ = ctx res := graphql.MarshalBoolean(v) return res } @@ -48225,6 +48398,8 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalBoolean(*v) return res } @@ -50438,6 +50613,8 @@ func (ec *executionContext) marshalOConfigEmail2ᚖstring(ctx context.Context, s if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalString(*v) return res } @@ -51652,6 +51829,8 @@ func (ec *executionContext) marshalOConfigHasuraAPIs2ᚖstring(ctx context.Conte if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalString(*v) return res } @@ -52156,6 +52335,8 @@ func (ec *executionContext) marshalOConfigInt162ᚖint16(ctx context.Context, se if v == nil { return graphql.Null } + _ = sel + _ = ctx res := types.MarshalInt16(*v) return res } @@ -52208,6 +52389,8 @@ func (ec *executionContext) marshalOConfigInt322ᚖint32(ctx context.Context, se if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalInt32(*v) return res } @@ -52268,6 +52451,8 @@ func (ec *executionContext) marshalOConfigInt642ᚖint64(ctx context.Context, se if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalInt64(*v) return res } @@ -52320,6 +52505,8 @@ func (ec *executionContext) marshalOConfigInt82ᚖint8(ctx context.Context, sel if v == nil { return graphql.Null } + _ = sel + _ = ctx res := types.MarshalInt8(*v) return res } @@ -52489,6 +52676,8 @@ func (ec *executionContext) marshalOConfigLocale2ᚖstring(ctx context.Context, if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalString(*v) return res } @@ -52634,6 +52823,8 @@ func (ec *executionContext) marshalOConfigPort2ᚖuint16(ctx context.Context, se if v == nil { return graphql.Null } + _ = sel + _ = ctx res := types.MarshalUint16(*v) return res } @@ -53167,6 +53358,8 @@ func (ec *executionContext) marshalOConfigRunServiceName2ᚖstring(ctx context.C if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalString(*v) return res } @@ -54141,6 +54334,8 @@ func (ec *executionContext) marshalOConfigUint162ᚖuint16(ctx context.Context, if v == nil { return graphql.Null } + _ = sel + _ = ctx res := types.MarshalUint16(*v) return res } @@ -54193,6 +54388,8 @@ func (ec *executionContext) marshalOConfigUint2ᚖuint(ctx context.Context, sel if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalUint(*v) return res } @@ -54245,6 +54442,8 @@ func (ec *executionContext) marshalOConfigUint322ᚖuint32(ctx context.Context, if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalUint32(*v) return res } @@ -54305,6 +54504,8 @@ func (ec *executionContext) marshalOConfigUint642ᚖuint64(ctx context.Context, if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalUint64(*v) return res } @@ -54357,6 +54558,8 @@ func (ec *executionContext) marshalOConfigUint82ᚖuint8(ctx context.Context, se if v == nil { return graphql.Null } + _ = sel + _ = ctx res := types.MarshalUint8(*v) return res } @@ -54425,6 +54628,8 @@ func (ec *executionContext) marshalOConfigUrl2ᚖstring(ctx context.Context, sel if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalString(*v) return res } @@ -54485,6 +54690,8 @@ func (ec *executionContext) marshalOConfigUserRole2ᚖstring(ctx context.Context if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalString(*v) return res } @@ -54545,6 +54752,7 @@ func (ec *executionContext) marshalOFloat2ᚖfloat64(ctx context.Context, sel as if v == nil { return graphql.Null } + _ = sel res := graphql.MarshalFloatContext(*v) return graphql.WrapContextMarshaler(ctx, res) } @@ -54597,6 +54805,8 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalInt(*v) return res } @@ -54649,6 +54859,8 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as if v == nil { return graphql.Null } + _ = sel + _ = ctx res := graphql.MarshalString(*v) return res } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_change_database_version.go b/vendor/github.com/nhost/be/services/mimir/graph/m_change_database_version.go index f81b8d9a2..99697974b 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_change_database_version.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_change_database_version.go @@ -17,6 +17,7 @@ func deptr[T any](v *T) T { if v == nil { return *new(T) } + return *v } @@ -36,6 +37,7 @@ func (r *mutationResolver) changeDatabaseVersionValidate( } oldMajorVersion := deptr(oldApp.Config.Postgres.Version)[:3] + newMajorVersion := deptr(newApp.Config.Postgres.Version)[:3] if oldMajorVersion >= newMajorVersion { return ErrDatabaseVersionMustBeGreater @@ -75,6 +77,7 @@ func (r *mutationResolver) changeDatabaseVersion( if _, err := newApp.ResolveConfig(r.schema, true); err != nil { return false, err } + if _, err := newApp.ResolveSystemConfig(r.schema); err != nil { return false, err } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_delete_config.go b/vendor/github.com/nhost/be/services/mimir/graph/m_delete_config.go index 5c9825ee3..3e54d6ad9 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_delete_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_delete_config.go @@ -23,6 +23,7 @@ func (r *mutationResolver) deleteConfig( if errors.Is(err, ErrAppNotFound) { return nil, nil //nolint: nilnil } + return nil, err } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_delete_run_service_config.go b/vendor/github.com/nhost/be/services/mimir/graph/m_delete_run_service_config.go index a35d763c5..96c0644b1 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_delete_run_service_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_delete_run_service_config.go @@ -24,8 +24,10 @@ func (r *mutationResolver) deleteRunServiceConfig( if errors.Is(err, ErrAppNotFound) { return nil, nil //nolint: nilnil } + return nil, err } + oldApp := r.data[i] i, err = oldApp.IndexService(serviceID) @@ -35,8 +37,10 @@ func (r *mutationResolver) deleteRunServiceConfig( if errors.Is(err, ErrServiceNotFound) { return nil, nil //nolint: nilnil } + return nil, err } + oldService := oldApp.Services[i] logger := nhcontext.LoggerFromContext(ctx).WithField("service_id", serviceID) diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_delete_secret.go b/vendor/github.com/nhost/be/services/mimir/graph/m_delete_secret.go index a0d2efa53..4e9cf8947 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_delete_secret.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_delete_secret.go @@ -47,6 +47,7 @@ func (r *mutationResolver) deleteSecret( if errors.As(err, &errNotFound) { return nil, NewVariableRequiredError(errNotFound.Name) } + return nil, err } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_insert_config.go b/vendor/github.com/nhost/be/services/mimir/graph/m_insert_config.go index 55ac597e7..0ae5265c4 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_insert_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_insert_config.go @@ -71,6 +71,7 @@ func (r *mutationResolver) insertConfig( if err != nil { return nil, err } + newApp.Config = config newApp.SystemConfig = systemConfig @@ -86,6 +87,7 @@ func (r *mutationResolver) insertConfig( } r.data = append(r.data, newApp) + return &model.ConfigInsertConfigResponse{ Config: newApp.Config, SystemConfig: newApp.SystemConfig, diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_insert_run_service_config.go b/vendor/github.com/nhost/be/services/mimir/graph/m_insert_run_service_config.go index e290cee7e..4179d2dbb 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_insert_run_service_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_insert_run_service_config.go @@ -34,10 +34,12 @@ func nameMustBeUnique(svcs Services, serviceID, name string) error { // we skip the service we are updating continue } + if svc.Config.Name == name { return ErrNameDuplicated } } + return nil } @@ -53,6 +55,7 @@ func (r *mutationResolver) insertRunServiceConfig( if err != nil { return nil, err } + app := r.data[i] serviceID := uuid.NewString() diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_replace_config_raw_json.go b/vendor/github.com/nhost/be/services/mimir/graph/m_replace_config_raw_json.go index 22d4cbfd8..7ba8c7ca3 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_replace_config_raw_json.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_replace_config_raw_json.go @@ -16,6 +16,7 @@ func (r *mutationResolver) replaceConfigRawJSON( dec := json.NewDecoder(strings.NewReader(rawJSON)) dec.DisallowUnknownFields() + if err := dec.Decode(&config); err != nil { return "", fmt.Errorf("failed to decode raw JSON: %w", err) } @@ -24,6 +25,7 @@ func (r *mutationResolver) replaceConfigRawJSON( if err != nil { return "", err } + if cfg == nil { return "{}", nil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_replace_run_service_config.go b/vendor/github.com/nhost/be/services/mimir/graph/m_replace_run_service_config.go index 16a1520e0..8c9820080 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_replace_run_service_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_replace_run_service_config.go @@ -21,6 +21,7 @@ func (r *mutationResolver) replaceRunServiceConfig( if err != nil { return nil, err } + app := r.data[i] if err := nameMustBeUnique(app.Services, serviceID, input.Name); err != nil { @@ -31,6 +32,7 @@ func (r *mutationResolver) replaceRunServiceConfig( if err != nil { return nil, err } + oldService := app.Services[i] newService := &Service{ @@ -56,5 +58,6 @@ func (r *mutationResolver) replaceRunServiceConfig( } app.Services[i] = newService + return newService.Config, nil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/m_update_run_service_config.go b/vendor/github.com/nhost/be/services/mimir/graph/m_update_run_service_config.go index 5814df913..25dab5013 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/m_update_run_service_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/m_update_run_service_config.go @@ -21,12 +21,14 @@ func (r *mutationResolver) updateRunServiceConfig( if err != nil { return nil, err } + app := r.data[i] i, err = app.IndexService(serviceID) if err != nil { return nil, err } + oldService := app.Services[i] if input.Name != nil { diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_app_secrets.go b/vendor/github.com/nhost/be/services/mimir/graph/q_app_secrets.go index 459c22304..3d58092ad 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_app_secrets.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_app_secrets.go @@ -18,5 +18,6 @@ func (r *queryResolver) appSecrets( return root.Secrets, nil } } + return nil, nil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_apps_secrets.go b/vendor/github.com/nhost/be/services/mimir/graph/q_apps_secrets.go index a49873701..6353ac147 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_apps_secrets.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_apps_secrets.go @@ -18,5 +18,6 @@ func (r *queryResolver) appsSecrets(_ context.Context) []*model.ConfigAppSecrets Secrets: root.Secrets, } } + return result } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_config.go b/vendor/github.com/nhost/be/services/mimir/graph/q_config.go index 50b1ca237..152118876 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_config.go @@ -24,6 +24,7 @@ func (r *queryResolver) config( if err != nil { return nil, err } + return cfg, nil } } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_config_raw_json.go b/vendor/github.com/nhost/be/services/mimir/graph/q_config_raw_json.go index f3d8d09bd..e57b2e78c 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_config_raw_json.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_config_raw_json.go @@ -16,8 +16,10 @@ func (r *queryResolver) configRawJSON( r.mu.RLock() defer r.mu.RUnlock() - var cfg *model.ConfigConfig - var err error + var ( + cfg *model.ConfigConfig + err error + ) for _, app := range r.data { if app.AppID == appID { @@ -30,6 +32,7 @@ func (r *queryResolver) configRawJSON( if err != nil { return "{}", err } + break } } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_configs.go b/vendor/github.com/nhost/be/services/mimir/graph/q_configs.go index d9d321dfe..43d89d162 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_configs.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_configs.go @@ -18,6 +18,7 @@ func (r *queryResolver) configs( defer r.mu.RUnlock() res := make([]*model.ConfigAppConfig, 0, 10) //nolint:mnd + for _, app := range r.data { logger = logger.WithField("app", app.AppID) @@ -31,11 +32,13 @@ func (r *queryResolver) configs( if !resolve { cfg = app.Config } + res = append(res, &model.ConfigAppConfig{ AppID: app.AppID, Config: cfg, }) } } + return res, nil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config.go b/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config.go index b1f395f34..f7fa5be20 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config.go @@ -21,8 +21,10 @@ func (r *queryResolver) runServiceConfig( if errors.Is(err, ErrAppNotFound) { return nil, nil //nolint: nilnil } + return nil, err } + app := r.data[i] for _, service := range app.Services { @@ -34,6 +36,7 @@ func (r *queryResolver) runServiceConfig( return nil, err } } + return cfg, nil } } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config_raw_json.go b/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config_raw_json.go index d00bf0175..a7839b1f6 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config_raw_json.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_config_raw_json.go @@ -19,6 +19,7 @@ func (r *queryResolver) runServiceConfigRawJSON( if err != nil { return "", err } + if cfg == nil { return "{}", nil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_configs.go b/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_configs.go index 60082ea0e..a64c84a7b 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_configs.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_run_service_configs.go @@ -19,10 +19,12 @@ func (r *queryResolver) runServiceConfigs( defer r.mu.RUnlock() services := make([]*model.ConfigRunServiceConfigWithID, 0, 10) //nolint:mnd + for _, app := range r.data { if appID != nil && app.AppID != *appID { continue } + for _, svc := range app.Services { logger = logger.WithField("service_id", svc.ServiceID) @@ -36,6 +38,7 @@ func (r *queryResolver) runServiceConfigs( if !resolve { cfg = svc.Config } + services = append(services, &model.ConfigRunServiceConfigWithID{ ServiceID: svc.ServiceID, Config: cfg, diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_system_config.go b/vendor/github.com/nhost/be/services/mimir/graph/q_system_config.go index f158d95ca..b67b727d6 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_system_config.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_system_config.go @@ -18,5 +18,6 @@ func (r *queryResolver) systemConfig( return app.SystemConfig, nil } } + return nil, nil //nolint: nilnil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/q_system_configs.go b/vendor/github.com/nhost/be/services/mimir/graph/q_system_configs.go index e0af19017..61a92b0b4 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/q_system_configs.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/q_system_configs.go @@ -14,6 +14,7 @@ func (r *queryResolver) systemConfigs( defer r.mu.RUnlock() res := make([]*model.ConfigAppSystemConfig, 0, 10) //nolint:mnd + for _, app := range r.data { cfg, err := app.ResolveSystemConfig(r.schema) if err != nil { @@ -27,5 +28,6 @@ func (r *queryResolver) systemConfigs( }) } } + return res, nil } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/resolver.go b/vendor/github.com/nhost/be/services/mimir/graph/resolver.go index 22d0a5861..fbdd9da62 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/resolver.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/resolver.go @@ -57,6 +57,7 @@ func NewResolver(data Data, nhostc nhost.Querier, plugins []Plugin) (*Resolver, if err != nil { return nil, fmt.Errorf("problem getting schema: %w", err) } + return &Resolver{ nhost: nhostc, data: data, @@ -78,6 +79,7 @@ func (r *Resolver) Config() []*model.ConfigAppConfig { Config: d.Config, } } + return configs } @@ -89,5 +91,6 @@ func (r *Resolver) AppsSecrets() []model.ConfigAppSecrets { Secrets: d.Secrets, } } + return values } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/router.go b/vendor/github.com/nhost/be/services/mimir/graph/router.go index 590844185..75de1149c 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/router.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/router.go @@ -59,10 +59,13 @@ func SetupRouter( { apiRoot.POST(graphQLPath, nhmiddleware.GraphqlAccounting, nhhandler.Graphql(srv)) apiRoot.GET(graphQLPath, nhhandler.Graphql(srv)) + if enablePlayground { apiRoot.GET("/", nhhandler.Playground(pathPrefix+graphQLPath)) } + apiRoot.GET("/version", nhhandler.Version(version)) } + return r } diff --git a/vendor/github.com/nhost/be/services/mimir/graph/schema.resolvers.go b/vendor/github.com/nhost/be/services/mimir/graph/schema.resolvers.go index 60684803c..888f92c6b 100644 --- a/vendor/github.com/nhost/be/services/mimir/graph/schema.resolvers.go +++ b/vendor/github.com/nhost/be/services/mimir/graph/schema.resolvers.go @@ -2,7 +2,7 @@ package graph // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.72 +// Code generated by github.com/99designs/gqlgen version v0.17.76 import ( "context" 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 b15fdb240..b12e570f3 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 @@ -9620,12 +9620,17 @@ type ConfigAuthsessionaccessTokenCustomClaims struct { Key string `json:"key" toml:"key"` Value string `json:"value" toml:"value"` + + Default *string `json:"default" toml:"default"` } func (o *ConfigAuthsessionaccessTokenCustomClaims) MarshalJSON() ([]byte, error) { m := make(map[string]any) m["key"] = o.Key m["value"] = o.Value + if o.Default != nil { + m["default"] = o.Default + } return json.Marshal(m) } @@ -9643,11 +9648,20 @@ func (o *ConfigAuthsessionaccessTokenCustomClaims) GetValue() string { return o.Value } +func (o *ConfigAuthsessionaccessTokenCustomClaims) GetDefault() *string { + if o == nil { + o = &ConfigAuthsessionaccessTokenCustomClaims{} + } + return o.Default +} + type ConfigAuthsessionaccessTokenCustomClaimsUpdateInput struct { - Key *string `json:"key,omitempty" toml:"key,omitempty"` - IsSetKey bool `json:"-"` - Value *string `json:"value,omitempty" toml:"value,omitempty"` - IsSetValue bool `json:"-"` + Key *string `json:"key,omitempty" toml:"key,omitempty"` + IsSetKey bool `json:"-"` + Value *string `json:"value,omitempty" toml:"value,omitempty"` + IsSetValue bool `json:"-"` + Default *string `json:"default,omitempty" toml:"default,omitempty"` + IsSetDefault bool `json:"-"` } func (o *ConfigAuthsessionaccessTokenCustomClaimsUpdateInput) UnmarshalGQL(v interface{}) error { @@ -9689,6 +9703,23 @@ func (o *ConfigAuthsessionaccessTokenCustomClaimsUpdateInput) UnmarshalGQL(v int } o.IsSetValue = true } + if v, ok := m["default"]; ok { + if v == nil { + o.Default = 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.Default = &x + } + o.IsSetDefault = true + } return nil } @@ -9714,6 +9745,13 @@ func (o *ConfigAuthsessionaccessTokenCustomClaimsUpdateInput) GetValue() *string return o.Value } +func (o *ConfigAuthsessionaccessTokenCustomClaimsUpdateInput) GetDefault() *string { + if o == nil { + o = &ConfigAuthsessionaccessTokenCustomClaimsUpdateInput{} + } + return o.Default +} + func (s *ConfigAuthsessionaccessTokenCustomClaims) Update(v *ConfigAuthsessionaccessTokenCustomClaimsUpdateInput) { if v == nil { return @@ -9728,11 +9766,15 @@ func (s *ConfigAuthsessionaccessTokenCustomClaims) Update(v *ConfigAuthsessionac s.Value = *v.Value } } + if v.IsSetDefault || v.Default != nil { + s.Default = v.Default + } } type ConfigAuthsessionaccessTokenCustomClaimsInsertInput struct { - Key string `json:"key,omitempty" toml:"key,omitempty"` - Value string `json:"value,omitempty" toml:"value,omitempty"` + Key string `json:"key,omitempty" toml:"key,omitempty"` + Value string `json:"value,omitempty" toml:"value,omitempty"` + Default *string `json:"default,omitempty" toml:"default,omitempty"` } func (o *ConfigAuthsessionaccessTokenCustomClaimsInsertInput) GetKey() string { @@ -9749,9 +9791,17 @@ func (o *ConfigAuthsessionaccessTokenCustomClaimsInsertInput) GetValue() string return o.Value } +func (o *ConfigAuthsessionaccessTokenCustomClaimsInsertInput) GetDefault() *string { + if o == nil { + o = &ConfigAuthsessionaccessTokenCustomClaimsInsertInput{} + } + return o.Default +} + func (s *ConfigAuthsessionaccessTokenCustomClaims) Insert(v *ConfigAuthsessionaccessTokenCustomClaimsInsertInput) { s.Key = v.Key s.Value = v.Value + s.Default = v.Default } func (s *ConfigAuthsessionaccessTokenCustomClaims) Clone() *ConfigAuthsessionaccessTokenCustomClaims { @@ -9762,15 +9812,17 @@ func (s *ConfigAuthsessionaccessTokenCustomClaims) Clone() *ConfigAuthsessionacc v := &ConfigAuthsessionaccessTokenCustomClaims{} v.Key = s.Key v.Value = s.Value + v.Default = s.Default return v } type ConfigAuthsessionaccessTokenCustomClaimsComparisonExp struct { - And []*ConfigAuthsessionaccessTokenCustomClaimsComparisonExp `json:"_and,omitempty"` - Not *ConfigAuthsessionaccessTokenCustomClaimsComparisonExp `json:"_not,omitempty"` - Or []*ConfigAuthsessionaccessTokenCustomClaimsComparisonExp `json:"_or,omitempty"` - Key *ConfigStringComparisonExp `json:"key,omitempty"` - Value *ConfigStringComparisonExp `json:"value,omitempty"` + And []*ConfigAuthsessionaccessTokenCustomClaimsComparisonExp `json:"_and,omitempty"` + Not *ConfigAuthsessionaccessTokenCustomClaimsComparisonExp `json:"_not,omitempty"` + Or []*ConfigAuthsessionaccessTokenCustomClaimsComparisonExp `json:"_or,omitempty"` + Key *ConfigStringComparisonExp `json:"key,omitempty"` + Value *ConfigStringComparisonExp `json:"value,omitempty"` + Default *ConfigStringComparisonExp `json:"default,omitempty"` } func (exp *ConfigAuthsessionaccessTokenCustomClaimsComparisonExp) Matches(o *ConfigAuthsessionaccessTokenCustomClaims) bool { @@ -9787,6 +9839,9 @@ func (exp *ConfigAuthsessionaccessTokenCustomClaimsComparisonExp) Matches(o *Con if !exp.Value.Matches(o.Value) { return false } + if o.Default != nil && !exp.Default.Matches(*o.Default) { + return false + } if exp.And != nil && !all(exp.And, o) { return false @@ -20111,6 +20166,8 @@ type ConfigPostgresSettings struct { MaxReplicationSlots *int32 `json:"maxReplicationSlots" toml:"maxReplicationSlots"` ArchiveTimeout *int32 `json:"archiveTimeout" toml:"archiveTimeout"` + + TrackIoTiming *string `json:"trackIoTiming" toml:"trackIoTiming"` } func (o *ConfigPostgresSettings) MarshalJSON() ([]byte, error) { @@ -20181,6 +20238,9 @@ func (o *ConfigPostgresSettings) MarshalJSON() ([]byte, error) { if o.ArchiveTimeout != nil { m["archiveTimeout"] = o.ArchiveTimeout } + if o.TrackIoTiming != nil { + m["trackIoTiming"] = o.TrackIoTiming + } return json.Marshal(m) } @@ -20338,6 +20398,13 @@ func (o *ConfigPostgresSettings) GetArchiveTimeout() *int32 { return o.ArchiveTimeout } +func (o *ConfigPostgresSettings) GetTrackIoTiming() *string { + if o == nil { + o = &ConfigPostgresSettings{} + } + return o.TrackIoTiming +} + type ConfigPostgresSettingsUpdateInput struct { Jit *string `json:"jit,omitempty" toml:"jit,omitempty"` IsSetJit bool `json:"-"` @@ -20383,6 +20450,8 @@ type ConfigPostgresSettingsUpdateInput struct { IsSetMaxReplicationSlots bool `json:"-"` ArchiveTimeout *int32 `json:"archiveTimeout,omitempty" toml:"archiveTimeout,omitempty"` IsSetArchiveTimeout bool `json:"-"` + TrackIoTiming *string `json:"trackIoTiming,omitempty" toml:"trackIoTiming,omitempty"` + IsSetTrackIoTiming bool `json:"-"` } func (o *ConfigPostgresSettingsUpdateInput) UnmarshalGQL(v interface{}) error { @@ -20764,6 +20833,23 @@ func (o *ConfigPostgresSettingsUpdateInput) UnmarshalGQL(v interface{}) error { } o.IsSetArchiveTimeout = true } + if v, ok := m["trackIoTiming"]; ok { + if v == nil { + o.TrackIoTiming = 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.TrackIoTiming = &x + } + o.IsSetTrackIoTiming = true + } return nil } @@ -20929,6 +21015,13 @@ func (o *ConfigPostgresSettingsUpdateInput) GetArchiveTimeout() *int32 { return o.ArchiveTimeout } +func (o *ConfigPostgresSettingsUpdateInput) GetTrackIoTiming() *string { + if o == nil { + o = &ConfigPostgresSettingsUpdateInput{} + } + return o.TrackIoTiming +} + func (s *ConfigPostgresSettings) Update(v *ConfigPostgresSettingsUpdateInput) { if v == nil { return @@ -20999,6 +21092,9 @@ func (s *ConfigPostgresSettings) Update(v *ConfigPostgresSettingsUpdateInput) { if v.IsSetArchiveTimeout || v.ArchiveTimeout != nil { s.ArchiveTimeout = v.ArchiveTimeout } + if v.IsSetTrackIoTiming || v.TrackIoTiming != nil { + s.TrackIoTiming = v.TrackIoTiming + } } type ConfigPostgresSettingsInsertInput struct { @@ -21024,6 +21120,7 @@ type ConfigPostgresSettingsInsertInput struct { MaxWalSenders *int32 `json:"maxWalSenders,omitempty" toml:"maxWalSenders,omitempty"` MaxReplicationSlots *int32 `json:"maxReplicationSlots,omitempty" toml:"maxReplicationSlots,omitempty"` ArchiveTimeout *int32 `json:"archiveTimeout,omitempty" toml:"archiveTimeout,omitempty"` + TrackIoTiming *string `json:"trackIoTiming,omitempty" toml:"trackIoTiming,omitempty"` } func (o *ConfigPostgresSettingsInsertInput) GetJit() *string { @@ -21180,6 +21277,13 @@ func (o *ConfigPostgresSettingsInsertInput) GetArchiveTimeout() *int32 { return o.ArchiveTimeout } +func (o *ConfigPostgresSettingsInsertInput) GetTrackIoTiming() *string { + if o == nil { + o = &ConfigPostgresSettingsInsertInput{} + } + return o.TrackIoTiming +} + func (s *ConfigPostgresSettings) Insert(v *ConfigPostgresSettingsInsertInput) { s.Jit = v.Jit s.MaxConnections = v.MaxConnections @@ -21203,6 +21307,7 @@ func (s *ConfigPostgresSettings) Insert(v *ConfigPostgresSettingsInsertInput) { s.MaxWalSenders = v.MaxWalSenders s.MaxReplicationSlots = v.MaxReplicationSlots s.ArchiveTimeout = v.ArchiveTimeout + s.TrackIoTiming = v.TrackIoTiming } func (s *ConfigPostgresSettings) Clone() *ConfigPostgresSettings { @@ -21233,6 +21338,7 @@ func (s *ConfigPostgresSettings) Clone() *ConfigPostgresSettings { v.MaxWalSenders = s.MaxWalSenders v.MaxReplicationSlots = s.MaxReplicationSlots v.ArchiveTimeout = s.ArchiveTimeout + v.TrackIoTiming = s.TrackIoTiming return v } @@ -21262,6 +21368,7 @@ type ConfigPostgresSettingsComparisonExp struct { MaxWalSenders *ConfigInt32ComparisonExp `json:"maxWalSenders,omitempty"` MaxReplicationSlots *ConfigInt32ComparisonExp `json:"maxReplicationSlots,omitempty"` ArchiveTimeout *ConfigInt32ComparisonExp `json:"archiveTimeout,omitempty"` + TrackIoTiming *ConfigStringComparisonExp `json:"trackIoTiming,omitempty"` } func (exp *ConfigPostgresSettingsComparisonExp) Matches(o *ConfigPostgresSettings) bool { @@ -21338,6 +21445,9 @@ func (exp *ConfigPostgresSettingsComparisonExp) Matches(o *ConfigPostgresSetting if o.ArchiveTimeout != nil && !exp.ArchiveTimeout.Matches(*o.ArchiveTimeout) { return false } + if o.TrackIoTiming != nil && !exp.TrackIoTiming.Matches(*o.TrackIoTiming) { + return false + } if exp.And != nil && !all(exp.And, o) { return false diff --git a/vendor/github.com/nhost/be/services/mimir/model/secrets.go b/vendor/github.com/nhost/be/services/mimir/model/secrets.go index 95068be11..ba896357b 100644 --- a/vendor/github.com/nhost/be/services/mimir/model/secrets.go +++ b/vendor/github.com/nhost/be/services/mimir/model/secrets.go @@ -7,5 +7,6 @@ func (ce Secrets) Clone() Secrets { for i, v := range ce { clone[i] = v.Clone() } + return clone } diff --git a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/ai.go b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/ai.go index f9bb0fc50..a572d36a9 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/ai.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/ai.go @@ -84,5 +84,6 @@ func AIEnv( //nolint:funlen Value: e.Value, }) } + return env } diff --git a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/common.go b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/common.go index f78010d64..d9642fee0 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/common.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/common.go @@ -12,6 +12,7 @@ func unptr[T any](t *T) T { if t == nil { return *new(T) } + return *t } @@ -26,6 +27,7 @@ func GetFQDN(subdomain, service, region, domain string) string { if region == "" { return fmt.Sprintf("%s.%s.%s", subdomain, service, domain) } + return fmt.Sprintf("%s.%s.%s.%s", subdomain, service, region, domain) } @@ -42,6 +44,7 @@ func GetFQDNURL(subdomain, service, region, domain string, useTLS bool, port uin if useTLS { protocol = "https" } + return fmt.Sprintf("%s://%s:%d", protocol, FQDN, port) } @@ -60,6 +63,7 @@ func GetFQDNOldURL(subdomain, domain string, useTLS bool, port uint) string { if useTLS { protocol = "https" } + return fmt.Sprintf("%s://%s:%d", protocol, GetFQDNOld(subdomain, domain), port) } @@ -90,13 +94,16 @@ func (t *claim) MarshalJSON() ([]byte, error) { if t.Value != nil { return json.Marshal(t.Value) //nolint:wrapcheck } + s := make(map[string]string) if t.Path != nil { s["path"] = *t.Path } + if t.Default != nil { s["default"] = *t.Default } + return json.Marshal(s) //nolint:wrapcheck } @@ -129,6 +136,7 @@ func marshalJWT(jwt *model.ConfigJWTSecret) ([]byte, error) { } } } + return json.Marshal(&jwtSecret{ //nolint:wrapcheck AllowedSkew: jwt.AllowedSkew, Audience: jwt.Audience, 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 82ac4de69..d83b5c68a 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 @@ -45,6 +45,7 @@ func SecretsResolver[T any]( if err != nil { return nil, fmt.Errorf("failed to validate config: %w", err) } + return cfg, nil } @@ -52,6 +53,7 @@ func SecretsResolver[T any]( // in the template using the syntax {{ variable_name }}. func interpolateTemplate(template []byte, vars map[string]any) ([]byte, error) { t := fasttemplate.New(unsafeBytes2String(template), "{{", "}}") + buf := bytes.NewBuffer(make([]byte, 0, len(template))) if _, err := t.ExecuteFunc(buf, templateResolver(vars)); err != nil { return nil, fmt.Errorf("failed to render template: %w", err) @@ -68,10 +70,12 @@ func templateResolver(vars map[string]any) func(w io.Writer, tag string) (int, e if !ok { return 0, &VariableNotFoundError{Name: tag} } + n, err := fmt.Fprint(w, v) if err != nil { return 0, fmt.Errorf("failed to write to buffer: %w", err) } + return n, nil } } diff --git a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura.go b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura.go index 31f3758ca..95128994e 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura.go @@ -18,6 +18,7 @@ func deptr[T any](x *T) T { if x == nil { return *new(T) } + return *x } diff --git a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura_auth.go b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura_auth.go index 553ba9382..6af72f8fa 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura_auth.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/hasura_auth.go @@ -36,6 +36,7 @@ func IsJWTSecretCompatibleWithHasuraAuth( if typ != nil && *typ != "" && key != nil && *key != "" { return strings.HasPrefix(*typ, "HS") || usesPubKey(typ, signingKey) } + return false } @@ -74,7 +75,7 @@ func getOauthSettings(c oauthsettings, provider string) []EnvVar { } } -func HasuraAuthEnv( //nolint:funlen,cyclop,maintidx +func HasuraAuthEnv( //nolint:funlen,cyclop,maintidx,gocyclo,gocognit config *model.ConfigConfig, hasuraGraphqlURL, authServerURL, @@ -89,8 +90,18 @@ func HasuraAuthEnv( //nolint:funlen,cyclop,maintidx map[string]string, len(config.GetAuth().Session.AccessToken.CustomClaims), ) + + customClaimsDefaults := make( + map[string]string, + len(config.GetAuth().Session.AccessToken.CustomClaims), + ) + for _, c := range config.GetAuth().Session.AccessToken.CustomClaims { customClaims[c.Key] = c.Value + + if c.Default != nil { + customClaimsDefaults[c.Key] = *c.Default + } } authJwtCustomClaims, err := json.Marshal(customClaims) @@ -98,6 +109,11 @@ func HasuraAuthEnv( //nolint:funlen,cyclop,maintidx return nil, fmt.Errorf("problem marshalling auth jwt custom claims: %w", err) } + authJwtCustomClaimsDefaults, err := json.Marshal(customClaimsDefaults) + if err != nil { + return nil, fmt.Errorf("problem marshalling auth jwt custom claims defaults: %w", err) + } + jwtSecret, err := marshalJWT(config.GetHasura().GetJwtSecrets()[0]) if err != nil { return nil, fmt.Errorf("could not marshal JWT secret: %w", err) @@ -109,10 +125,12 @@ func HasuraAuthEnv( //nolint:funlen,cyclop,maintidx } dbURL := databaseURL + version := *config.GetAuth().GetVersion() if version != "0.0.0-dev" && CompareVersions(version, "0.30.999999") <= 0 { dbURL = databaseMigrationURL } + env := []EnvVar{ { Name: "HASURA_GRAPHQL_DATABASE_URL", @@ -321,6 +339,12 @@ func HasuraAuthEnv( //nolint:funlen,cyclop,maintidx IsSecret: false, SecretName: "", }, + { + Name: "AUTH_JWT_CUSTOM_CLAIMS_DEFAULTS", + Value: string(authJwtCustomClaimsDefaults), + IsSecret: false, + SecretName: "", + }, { Name: "AUTH_EMAIL_PASSWORDLESS_ENABLED", Value: Stringify( 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 fd4d99011..8d953897e 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 @@ -190,6 +190,14 @@ func PostgresEnv( //nolint:funlen *config.GetPostgres().GetSettings().GetArchiveTimeout(), ), }, + { + Name: "TRACK_IO_TIMING", + Value: Stringify( + *config.GetPostgres().GetSettings().GetTrackIoTiming(), + ), + IsSecret: false, + SecretName: "", + }, }...) } diff --git a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/versions.go b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/versions.go index 828baefe6..3d9b82b31 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/appconfig/versions.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/appconfig/versions.go @@ -11,6 +11,7 @@ func CompareVersions(a, b string) int { if strings.Contains(s, ":") { return strings.Split(s, ":")[1] } + return s } @@ -18,6 +19,7 @@ func CompareVersions(a, b string) int { if !strings.HasPrefix(s, "v") { return "v" + s } + return s } @@ -30,6 +32,7 @@ func CompareVersions(a, b string) int { if !semver.IsValid(a) { return 1 } + if !semver.IsValid(b) { return -1 } 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 f7c88a49f..a66dcb5a1 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/schema.cue +++ b/vendor/github.com/nhost/be/services/mimir/schema/schema.cue @@ -254,7 +254,7 @@ import ( #Postgres: { // Version of postgres, you can see available versions in the URL below: // https://hub.docker.com/r/nhost/postgres/tags - version: string | *"14.17-20250530-1" + version: string | *"14.17-20250728-1" // Resources for the service resources: { @@ -291,6 +291,7 @@ import ( maxWalSenders: int32 | *10 maxReplicationSlots: int32 | *10 archiveTimeout: int32 & >=300 & <=1073741823 | *300 + trackIoTiming: "on" | *"off" // if pitr is on we need walLevel to set to replica or logical _validateWalLevelIsLogicalOrReplicaIfPitrIsEnabled: ( pitr == _|_ | walLevel == "replica" | walLevel == "logical") & true @cuegraph(skip) @@ -382,8 +383,9 @@ import ( expiresIn: uint32 | *900 // AUTH_JWT_CUSTOM_CLAIMS customClaims: [...{ - key: =~"[a-zA-Z_]{1,}[a-zA-Z0-9_]*" - value: string + key: =~"[a-zA-Z_]{1,}[a-zA-Z0-9_]*" + value: string + default?: string }] | *[] } diff --git a/vendor/github.com/nhost/be/services/mimir/schema/schema.go b/vendor/github.com/nhost/be/services/mimir/schema/schema.go index eda7db870..e98f2c93b 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/schema.go +++ b/vendor/github.com/nhost/be/services/mimir/schema/schema.go @@ -24,6 +24,7 @@ func (e *ConfigNotValidError) Error() string { if e.err == nil { return "config is not valid" } + return "config is not valid: " + e.err.Error() } @@ -37,6 +38,7 @@ type Schema struct { func New() (*Schema, error) { ctx := cuecontext.New() + v := ctx.CompileBytes(schemabytes) if v.Err() != nil { return nil, fmt.Errorf("problem compiling cue schema: %w", v.Err()) @@ -60,6 +62,7 @@ func (s *Schema) unify(config any, model string) (*cue.Value, error) { } ctx := cuecontext.New() + v := ctx.BuildExpr(expr) if v.Err() != nil { return nil, fmt.Errorf("problem building cue expression: %w", v.Err()) @@ -71,6 +74,7 @@ func (s *Schema) unify(config any, model string) (*cue.Value, error) { if u.Err() != nil { return nil, NewConfigNotValidError(u.Err()) } + return &u, nil } 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 278be9e93..33836c0f2 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 @@ -1561,16 +1561,22 @@ type ConfigAuthsessionaccessTokenCustomClaims { """ value: String! + """ + + """ + default: String } input ConfigAuthsessionaccessTokenCustomClaimsUpdateInput { key: String value: String + default: String } input ConfigAuthsessionaccessTokenCustomClaimsInsertInput { key: String! value: String! + default: String } input ConfigAuthsessionaccessTokenCustomClaimsComparisonExp { @@ -1579,6 +1585,7 @@ input ConfigAuthsessionaccessTokenCustomClaimsComparisonExp { _or: [ConfigAuthsessionaccessTokenCustomClaimsComparisonExp!] key: ConfigStringComparisonExp value: ConfigStringComparisonExp + default: ConfigStringComparisonExp } """ @@ -3211,6 +3218,10 @@ type ConfigPostgresSettings { """ archiveTimeout: ConfigInt32 + """ + + """ + trackIoTiming: String } input ConfigPostgresSettingsUpdateInput { @@ -3236,6 +3247,7 @@ input ConfigPostgresSettingsUpdateInput { maxWalSenders: ConfigInt32 maxReplicationSlots: ConfigInt32 archiveTimeout: ConfigInt32 + trackIoTiming: String } input ConfigPostgresSettingsInsertInput { @@ -3261,6 +3273,7 @@ input ConfigPostgresSettingsInsertInput { maxWalSenders: ConfigInt32 maxReplicationSlots: ConfigInt32 archiveTimeout: ConfigInt32 + trackIoTiming: String } input ConfigPostgresSettingsComparisonExp { @@ -3289,6 +3302,7 @@ input ConfigPostgresSettingsComparisonExp { maxWalSenders: ConfigInt32ComparisonExp maxReplicationSlots: ConfigInt32ComparisonExp archiveTimeout: ConfigInt32ComparisonExp + trackIoTiming: ConfigStringComparisonExp } """ diff --git a/vendor/github.com/nhost/be/tools/cuegraph/types/int16.go b/vendor/github.com/nhost/be/tools/cuegraph/types/int16.go index 0cf489caf..6d201b1b7 100644 --- a/vendor/github.com/nhost/be/tools/cuegraph/types/int16.go +++ b/vendor/github.com/nhost/be/tools/cuegraph/types/int16.go @@ -26,6 +26,7 @@ func UnmarshalInt16(v interface{}) (int16, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse string: %w", err) } + return int16(iv), nil case int: return int16(v), nil //nolint:gosec @@ -36,8 +37,9 @@ func UnmarshalInt16(v interface{}) (int16, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse json.Number: %w", err) } + return int16(iv), nil //nolint:gosec default: - return 0, fmt.Errorf("%T is not an int", v) //nolint: goerr113 + return 0, fmt.Errorf("%T is not an int", v) //nolint: err113 } } diff --git a/vendor/github.com/nhost/be/tools/cuegraph/types/int8.go b/vendor/github.com/nhost/be/tools/cuegraph/types/int8.go index 27c4a814f..0508023e8 100644 --- a/vendor/github.com/nhost/be/tools/cuegraph/types/int8.go +++ b/vendor/github.com/nhost/be/tools/cuegraph/types/int8.go @@ -26,6 +26,7 @@ func UnmarshalInt8(v interface{}) (int8, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse string: %w", err) } + return int8(iv), nil case int: return int8(v), nil //nolint:gosec @@ -36,8 +37,9 @@ func UnmarshalInt8(v interface{}) (int8, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse json.Number: %w", err) } + return int8(iv), nil //nolint:gosec default: - return 0, fmt.Errorf("%T is not an int", v) //nolint: goerr113 + return 0, fmt.Errorf("%T is not an int", v) //nolint: err113 } } diff --git a/vendor/github.com/nhost/be/tools/cuegraph/types/uint16.go b/vendor/github.com/nhost/be/tools/cuegraph/types/uint16.go index 5b618dceb..bda77d1cb 100644 --- a/vendor/github.com/nhost/be/tools/cuegraph/types/uint16.go +++ b/vendor/github.com/nhost/be/tools/cuegraph/types/uint16.go @@ -27,6 +27,7 @@ func UnmarshalUint16(v interface{}) (uint16, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse string: %w", err) } + return uint16(iv), nil //nolint:gosec case int: return uint16(v), nil //nolint:gosec @@ -37,8 +38,9 @@ func UnmarshalUint16(v interface{}) (uint16, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse json.Number: %w", err) } + return uint16(iv), nil default: - return 0, fmt.Errorf("%T is not an uint", v) //nolint: goerr113 + return 0, fmt.Errorf("%T is not an uint", v) //nolint: err113 } } diff --git a/vendor/github.com/nhost/be/tools/cuegraph/types/uint8.go b/vendor/github.com/nhost/be/tools/cuegraph/types/uint8.go index ff1fc0a54..7ebbb4453 100644 --- a/vendor/github.com/nhost/be/tools/cuegraph/types/uint8.go +++ b/vendor/github.com/nhost/be/tools/cuegraph/types/uint8.go @@ -1,4 +1,4 @@ -package types //nolint: dupl +package types //nolint:dupl,revive import ( "encoding/json" @@ -26,6 +26,7 @@ func UnmarshalUint8(v interface{}) (uint8, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse string: %w", err) } + return uint8(iv), nil //nolint:gosec case int: return uint8(v), nil //nolint:gosec @@ -36,8 +37,9 @@ func UnmarshalUint8(v interface{}) (uint8, error) { if err != nil { return 0, fmt.Errorf("problem trying to parse json.Number: %w", err) } + return uint8(iv), nil default: - return 0, fmt.Errorf("%T is not an uint", v) //nolint: goerr113 + return 0, fmt.Errorf("%T is not an uint", v) //nolint: err113 } } diff --git a/vendor/github.com/vektah/gqlparser/v2/gqlerror/error.go b/vendor/github.com/vektah/gqlparser/v2/gqlerror/error.go index ca9036ca7..d9f202887 100644 --- a/vendor/github.com/vektah/gqlparser/v2/gqlerror/error.go +++ b/vendor/github.com/vektah/gqlparser/v2/gqlerror/error.go @@ -164,6 +164,15 @@ func ErrorPathf(path ast.Path, message string, args ...interface{}) *Error { } func ErrorPosf(pos *ast.Position, message string, args ...interface{}) *Error { + if pos == nil { + return ErrorLocf( + "", + -1, + -1, + message, + args..., + ) + } return ErrorLocf( pos.Src.Name, pos.Line, diff --git a/vendor/github.com/vektah/gqlparser/v2/gqlparser.go b/vendor/github.com/vektah/gqlparser/v2/gqlparser.go index d404fd0b5..2b22894b5 100644 --- a/vendor/github.com/vektah/gqlparser/v2/gqlparser.go +++ b/vendor/github.com/vektah/gqlparser/v2/gqlparser.go @@ -5,9 +5,7 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" "github.com/vektah/gqlparser/v2/parser" "github.com/vektah/gqlparser/v2/validator" - - // Blank import is used to load up the validator rules. - _ "github.com/vektah/gqlparser/v2/validator/rules" + "github.com/vektah/gqlparser/v2/validator/rules" ) func LoadSchema(str ...*ast.Source) (*ast.Schema, error) { @@ -30,6 +28,7 @@ func MustLoadSchema(str ...*ast.Source) *ast.Schema { return s } +// Deprecated: use LoadQueryWithRules instead. func LoadQuery(schema *ast.Schema, str string) (*ast.QueryDocument, gqlerror.List) { query, err := parser.ParseQuery(&ast.Source{Input: str}) if err != nil { @@ -47,6 +46,24 @@ func LoadQuery(schema *ast.Schema, str string) (*ast.QueryDocument, gqlerror.Lis return query, nil } +func LoadQueryWithRules(schema *ast.Schema, str string, rules *rules.Rules) (*ast.QueryDocument, gqlerror.List) { + query, err := parser.ParseQuery(&ast.Source{Input: str}) + if err != nil { + gqlErr, ok := err.(*gqlerror.Error) + if ok { + return nil, gqlerror.List{gqlErr} + } + return nil, gqlerror.List{gqlerror.Wrap(err)} + } + errs := validator.ValidateWithRules(schema, query, rules) + if len(errs) > 0 { + return nil, errs + } + + return query, nil +} + +// Deprecated: use MustLoadQueryWithRules instead. func MustLoadQuery(schema *ast.Schema, str string) *ast.QueryDocument { q, err := LoadQuery(schema, str) if err != nil { @@ -54,3 +71,11 @@ func MustLoadQuery(schema *ast.Schema, str string) *ast.QueryDocument { } return q } + +func MustLoadQueryWithRules(schema *ast.Schema, str string, rules *rules.Rules) *ast.QueryDocument { + q, err := LoadQueryWithRules(schema, str, rules) + if err != nil { + panic(err) + } + return q +} diff --git a/vendor/github.com/vektah/gqlparser/v2/parser/parser.go b/vendor/github.com/vektah/gqlparser/v2/parser/parser.go index bfcf7ea49..2aba98379 100644 --- a/vendor/github.com/vektah/gqlparser/v2/parser/parser.go +++ b/vendor/github.com/vektah/gqlparser/v2/parser/parser.go @@ -1,7 +1,6 @@ package parser import ( - "fmt" "strconv" "github.com/vektah/gqlparser/v2/ast" @@ -106,7 +105,7 @@ func (p *parser) next() lexer.Token { // Increment the token count before reading the next token p.tokenCount++ if p.maxTokenLimit != 0 && p.tokenCount > p.maxTokenLimit { - p.err = fmt.Errorf("exceeded token limit of %d", p.maxTokenLimit) + p.err = gqlerror.Errorf("exceeded token limit of %d", p.maxTokenLimit) return p.prev } if p.peeked { diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/core/core.go b/vendor/github.com/vektah/gqlparser/v2/validator/core/core.go new file mode 100644 index 000000000..7a6295c2f --- /dev/null +++ b/vendor/github.com/vektah/gqlparser/v2/validator/core/core.go @@ -0,0 +1,24 @@ +package core + +import ( + "github.com/vektah/gqlparser/v2/gqlerror" +) + +type AddErrFunc func(options ...ErrorOption) + +type RuleFunc func(observers *Events, addError AddErrFunc) + +type Rule struct { + Name string + RuleFunc RuleFunc +} + +// NameSorter sorts Rules by name. +// usage: sort.Sort(core.NameSorter(specifiedRules)) +type NameSorter []Rule + +func (a NameSorter) Len() int { return len(a) } +func (a NameSorter) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a NameSorter) Less(i, j int) bool { return a[i].Name < a[j].Name } + +type ErrorOption func(err *gqlerror.Error) diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/core/helpers.go b/vendor/github.com/vektah/gqlparser/v2/validator/core/helpers.go new file mode 100644 index 000000000..b395a8402 --- /dev/null +++ b/vendor/github.com/vektah/gqlparser/v2/validator/core/helpers.go @@ -0,0 +1,154 @@ +package core + +import ( + "bytes" + "fmt" + "math" + "sort" + "strings" + + "github.com/agnivade/levenshtein" + "github.com/vektah/gqlparser/v2/ast" + "github.com/vektah/gqlparser/v2/gqlerror" +) + +func Message(msg string, args ...interface{}) ErrorOption { + return func(err *gqlerror.Error) { + err.Message += fmt.Sprintf(msg, args...) + } +} + +func At(position *ast.Position) ErrorOption { + return func(err *gqlerror.Error) { + if position == nil { + return + } + err.Locations = append(err.Locations, gqlerror.Location{ + Line: position.Line, + Column: position.Column, + }) + if position.Src.Name != "" { + err.SetFile(position.Src.Name) + } + } +} + +func SuggestListQuoted(prefix string, typed string, suggestions []string) ErrorOption { + suggested := SuggestionList(typed, suggestions) + return func(err *gqlerror.Error) { + if len(suggested) > 0 { + err.Message += " " + prefix + " " + QuotedOrList(suggested...) + "?" + } + } +} + +func SuggestListUnquoted(prefix string, typed string, suggestions []string) ErrorOption { + suggested := SuggestionList(typed, suggestions) + return func(err *gqlerror.Error) { + if len(suggested) > 0 { + err.Message += " " + prefix + " " + OrList(suggested...) + "?" + } + } +} + +func Suggestf(suggestion string, args ...interface{}) ErrorOption { + return func(err *gqlerror.Error) { + err.Message += " Did you mean " + fmt.Sprintf(suggestion, args...) + "?" + } +} + +// Given [ A, B, C ] return '"A", "B", or "C"'. +func QuotedOrList(items ...string) string { + itemsQuoted := make([]string, len(items)) + for i, item := range items { + itemsQuoted[i] = `"` + item + `"` + } + return OrList(itemsQuoted...) +} + +// Given [ A, B, C ] return 'A, B, or C'. +func OrList(items ...string) string { + var buf bytes.Buffer + + if len(items) > 5 { + items = items[:5] + } + if len(items) == 2 { + buf.WriteString(items[0]) + buf.WriteString(" or ") + buf.WriteString(items[1]) + return buf.String() + } + + for i, item := range items { + if i != 0 { + if i == len(items)-1 { + buf.WriteString(", or ") + } else { + buf.WriteString(", ") + } + } + buf.WriteString(item) + } + return buf.String() +} + +// Given an invalid input string and a list of valid options, returns a filtered +// list of valid options sorted based on their similarity with the input. +func SuggestionList(input string, options []string) []string { + var results []string + optionsByDistance := map[string]int{} + + for _, option := range options { + distance := lexicalDistance(input, option) + threshold := calcThreshold(input) + if distance <= threshold { + results = append(results, option) + optionsByDistance[option] = distance + } + } + + sort.Slice(results, func(i, j int) bool { + return optionsByDistance[results[i]] < optionsByDistance[results[j]] + }) + return results +} + +func calcThreshold(a string) (threshold int) { + // the logic is copied from here + // https://github.com/graphql/graphql-js/blob/47bd8c8897c72d3efc17ecb1599a95cee6bac5e8/src/jsutils/suggestionList.ts#L14 + threshold = int(math.Floor(float64(len(a))*0.4) + 1) + + if threshold < 1 { + threshold = 1 + } + return +} + +// Computes the lexical distance between strings A and B. +// +// The "distance" between two strings is given by counting the minimum number +// of edits needed to transform string A into string B. An edit can be an +// insertion, deletion, or substitution of a single character, or a swap of two +// adjacent characters. +// +// Includes a custom alteration from Damerau-Levenshtein to treat case changes +// as a single edit which helps identify mis-cased values with an edit distance +// of 1. +// +// This distance can be useful for detecting typos in input or sorting +func lexicalDistance(a, b string) int { + if a == b { + return 0 + } + + a = strings.ToLower(a) + b = strings.ToLower(b) + + // Any case change counts as a single edit + if a == b { + return 1 + } + + return levenshtein.ComputeDistance(a, b) +} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/walk.go b/vendor/github.com/vektah/gqlparser/v2/validator/core/walk.go similarity index 99% rename from vendor/github.com/vektah/gqlparser/v2/validator/walk.go rename to vendor/github.com/vektah/gqlparser/v2/validator/core/walk.go index d3140746f..09a3016fd 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/walk.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/core/walk.go @@ -1,4 +1,4 @@ -package validator +package core import ( "context" diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/error.go b/vendor/github.com/vektah/gqlparser/v2/validator/error.go deleted file mode 100644 index f8f76055a..000000000 --- a/vendor/github.com/vektah/gqlparser/v2/validator/error.go +++ /dev/null @@ -1,55 +0,0 @@ -package validator - -import ( - "fmt" - - "github.com/vektah/gqlparser/v2/ast" - "github.com/vektah/gqlparser/v2/gqlerror" -) - -type ErrorOption func(err *gqlerror.Error) - -func Message(msg string, args ...interface{}) ErrorOption { - return func(err *gqlerror.Error) { - err.Message += fmt.Sprintf(msg, args...) - } -} - -func At(position *ast.Position) ErrorOption { - return func(err *gqlerror.Error) { - if position == nil { - return - } - err.Locations = append(err.Locations, gqlerror.Location{ - Line: position.Line, - Column: position.Column, - }) - if position.Src.Name != "" { - err.SetFile(position.Src.Name) - } - } -} - -func SuggestListQuoted(prefix string, typed string, suggestions []string) ErrorOption { - suggested := SuggestionList(typed, suggestions) - return func(err *gqlerror.Error) { - if len(suggested) > 0 { - err.Message += " " + prefix + " " + QuotedOrList(suggested...) + "?" - } - } -} - -func SuggestListUnquoted(prefix string, typed string, suggestions []string) ErrorOption { - suggested := SuggestionList(typed, suggestions) - return func(err *gqlerror.Error) { - if len(suggested) > 0 { - err.Message += " " + prefix + " " + OrList(suggested...) + "?" - } - } -} - -func Suggestf(suggestion string, args ...interface{}) ErrorOption { - return func(err *gqlerror.Error) { - err.Message += " Did you mean " + fmt.Sprintf(suggestion, args...) + "?" - } -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/messaging.go b/vendor/github.com/vektah/gqlparser/v2/validator/messaging.go deleted file mode 100644 index f1ab5873f..000000000 --- a/vendor/github.com/vektah/gqlparser/v2/validator/messaging.go +++ /dev/null @@ -1,39 +0,0 @@ -package validator - -import "bytes" - -// Given [ A, B, C ] return '"A", "B", or "C"'. -func QuotedOrList(items ...string) string { - itemsQuoted := make([]string, len(items)) - for i, item := range items { - itemsQuoted[i] = `"` + item + `"` - } - return OrList(itemsQuoted...) -} - -// Given [ A, B, C ] return 'A, B, or C'. -func OrList(items ...string) string { - var buf bytes.Buffer - - if len(items) > 5 { - items = items[:5] - } - if len(items) == 2 { - buf.WriteString(items[0]) - buf.WriteString(" or ") - buf.WriteString(items[1]) - return buf.String() - } - - for i, item := range items { - if i != 0 { - if i == len(items)-1 { - buf.WriteString(", or ") - } else { - buf.WriteString(", ") - } - } - buf.WriteString(item) - } - return buf.String() -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/fields_on_correct_type.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/fields_on_correct_type.go index b57d2a901..e4a67eb0c 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/fields_on_correct_type.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/fields_on_correct_type.go @@ -8,7 +8,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) func ruleFuncFieldsOnCorrectType(observers *Events, addError AddErrFunc, disableSuggestion bool) { @@ -48,10 +48,6 @@ var FieldsOnCorrectTypeRuleWithoutSuggestions = Rule{ }, } -func init() { - AddRule(FieldsOnCorrectTypeRule.Name, FieldsOnCorrectTypeRule.RuleFunc) -} - // Go through all the implementations of type, as well as the interfaces // that they implement. If any of those types include the provided field, // suggest them, sorted by how often the type is referenced, starting diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/fragments_on_composite_types.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/fragments_on_composite_types.go index a88e3f1cf..8fb269258 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/fragments_on_composite_types.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/fragments_on_composite_types.go @@ -6,7 +6,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var FragmentsOnCompositeTypesRule = Rule{ @@ -40,7 +40,3 @@ var FragmentsOnCompositeTypesRule = Rule{ }) }, } - -func init() { - AddRule(FragmentsOnCompositeTypesRule.Name, FragmentsOnCompositeTypesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_argument_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_argument_names.go index 83b4e0575..4c065a715 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_argument_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_argument_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) func ruleFuncKnownArgumentNames(observers *Events, addError AddErrFunc, disableSuggestion bool) { @@ -82,7 +82,3 @@ var KnownArgumentNamesRuleWithoutSuggestions = Rule{ ruleFuncKnownArgumentNames(observers, addError, true) }, } - -func init() { - AddRule(KnownArgumentNamesRule.Name, KnownArgumentNamesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_directives.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_directives.go index ccb5efeb9..2430d29b2 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_directives.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_directives.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var KnownDirectivesRule = Rule{ @@ -48,7 +48,3 @@ var KnownDirectivesRule = Rule{ }) }, } - -func init() { - AddRule(KnownDirectivesRule.Name, KnownDirectivesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_fragment_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_fragment_names.go index 525698fb9..c9b9f90d4 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_fragment_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_fragment_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var KnownFragmentNamesRule = Rule{ @@ -20,7 +20,3 @@ var KnownFragmentNamesRule = Rule{ }) }, } - -func init() { - AddRule(KnownFragmentNamesRule.Name, KnownFragmentNamesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_root_type.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_root_type.go index aa66d16c2..b67da68ce 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_root_type.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_root_type.go @@ -6,7 +6,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var KnownRootTypeRule = Rule{ @@ -36,7 +36,3 @@ var KnownRootTypeRule = Rule{ }) }, } - -func init() { - AddRule(KnownRootTypeRule.Name, KnownRootTypeRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_type_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_type_names.go index ef85c58e6..a0f10fba7 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_type_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/known_type_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) func ruleFuncKnownTypeNames(observers *Events, addError AddErrFunc, disableSuggestion bool) { @@ -78,7 +78,3 @@ var KnownTypeNamesRuleWithoutSuggestions = Rule{ ruleFuncKnownTypeNames(observers, addError, true) }, } - -func init() { - AddRule(KnownTypeNamesRule.Name, KnownTypeNamesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/lone_anonymous_operation.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/lone_anonymous_operation.go index 6e246f715..dfa851c57 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/lone_anonymous_operation.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/lone_anonymous_operation.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var LoneAnonymousOperationRule = Rule{ @@ -20,7 +20,3 @@ var LoneAnonymousOperationRule = Rule{ }) }, } - -func init() { - AddRule(LoneAnonymousOperationRule.Name, LoneAnonymousOperationRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/max_introspection_depth.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/max_introspection_depth.go index 57a68b32b..651b23b4e 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/max_introspection_depth.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/max_introspection_depth.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) const maxListsDepth = 3 @@ -84,7 +84,3 @@ func checkDepthFragmentSpread(fragmentSpread *ast.FragmentSpread, visitedFragmen defer delete(visitedFragments, fragmentName) return checkDepthSelectionSet(fragment.SelectionSet, visitedFragments, depth) } - -func init() { - AddRule(MaxIntrospectionDepth.Name, MaxIntrospectionDepth.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_fragment_cycles.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_fragment_cycles.go index 4e7907e24..fb3ac6ad3 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_fragment_cycles.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_fragment_cycles.go @@ -7,7 +7,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var NoFragmentCyclesRule = Rule{ @@ -71,10 +71,6 @@ var NoFragmentCyclesRule = Rule{ }, } -func init() { - AddRule(NoFragmentCyclesRule.Name, NoFragmentCyclesRule.RuleFunc) -} - func getFragmentSpreads(node ast.SelectionSet) []*ast.FragmentSpread { var spreads []*ast.FragmentSpread diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_undefined_variables.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_undefined_variables.go index 64f2dc776..562d7f19c 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_undefined_variables.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_undefined_variables.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var NoUndefinedVariablesRule = Rule{ @@ -29,7 +29,3 @@ var NoUndefinedVariablesRule = Rule{ }) }, } - -func init() { - AddRule(NoUndefinedVariablesRule.Name, NoUndefinedVariablesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_fragments.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_fragments.go index a914ee6d3..6d27e11e9 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_fragments.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_fragments.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var NoUnusedFragmentsRule = Rule{ @@ -30,7 +30,3 @@ var NoUnusedFragmentsRule = Rule{ }) }, } - -func init() { - AddRule(NoUnusedFragmentsRule.Name, NoUnusedFragmentsRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_variables.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_variables.go index daed80ebb..a4ce07090 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_variables.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/no_unused_variables.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var NoUnusedVariablesRule = Rule{ @@ -31,7 +31,3 @@ var NoUnusedVariablesRule = Rule{ }) }, } - -func init() { - AddRule(NoUnusedVariablesRule.Name, NoUnusedVariablesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/overlapping_fields_can_be_merged.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/overlapping_fields_can_be_merged.go index 129568220..9e843e760 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/overlapping_fields_can_be_merged.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/overlapping_fields_can_be_merged.go @@ -8,7 +8,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var OverlappingFieldsCanBeMergedRule = Rule{ @@ -108,10 +108,6 @@ var OverlappingFieldsCanBeMergedRule = Rule{ }, } -func init() { - AddRule(OverlappingFieldsCanBeMergedRule.Name, OverlappingFieldsCanBeMergedRule.RuleFunc) -} - type pairSet struct { data map[string]map[string]bool } diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/possible_fragment_spreads.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/possible_fragment_spreads.go index b81f37565..f932ac8c2 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/possible_fragment_spreads.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/possible_fragment_spreads.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var PossibleFragmentSpreadsRule = Rule{ @@ -68,7 +68,3 @@ var PossibleFragmentSpreadsRule = Rule{ }) }, } - -func init() { - AddRule(PossibleFragmentSpreadsRule.Name, PossibleFragmentSpreadsRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/provided_required_arguments.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/provided_required_arguments.go index 90667af23..fc1a6a476 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/provided_required_arguments.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/provided_required_arguments.go @@ -3,7 +3,7 @@ package rules import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var ProvidedRequiredArgumentsRule = Rule{ @@ -62,7 +62,3 @@ var ProvidedRequiredArgumentsRule = Rule{ }) }, } - -func init() { - AddRule(ProvidedRequiredArgumentsRule.Name, ProvidedRequiredArgumentsRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/rules.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/rules.go new file mode 100644 index 000000000..803543ed1 --- /dev/null +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/rules.go @@ -0,0 +1,119 @@ +package rules + +import ( + "slices" + + "github.com/vektah/gqlparser/v2/validator/core" +) + +// Rules manages GraphQL validation rules. +type Rules struct { + rules map[string]core.RuleFunc + ruleNameKeys []string // for deterministic order +} + +// NewRules creates a Rules instance with the specified rules. +func NewRules(rs ...core.Rule) *Rules { + r := &Rules{ + rules: make(map[string]core.RuleFunc), + } + + for _, rule := range rs { + r.AddRule(rule.Name, rule.RuleFunc) + } + + return r +} + +// NewDefaultRules creates a Rules instance containing the default GraphQL validation rule set. +func NewDefaultRules() *Rules { + rules := []core.Rule{ + FieldsOnCorrectTypeRule, + FragmentsOnCompositeTypesRule, + KnownArgumentNamesRule, + KnownDirectivesRule, + KnownFragmentNamesRule, + KnownRootTypeRule, + KnownTypeNamesRule, + LoneAnonymousOperationRule, + MaxIntrospectionDepth, + NoFragmentCyclesRule, + NoUndefinedVariablesRule, + NoUnusedFragmentsRule, + NoUnusedVariablesRule, + OverlappingFieldsCanBeMergedRule, + PossibleFragmentSpreadsRule, + ProvidedRequiredArgumentsRule, + ScalarLeafsRule, + SingleFieldSubscriptionsRule, + UniqueArgumentNamesRule, + UniqueDirectivesPerLocationRule, + UniqueFragmentNamesRule, + UniqueInputFieldNamesRule, + UniqueOperationNamesRule, + UniqueVariableNamesRule, + ValuesOfCorrectTypeRule, + VariablesAreInputTypesRule, + VariablesInAllowedPositionRule, + } + + r := NewRules(rules...) + + return r +} + +// AddRule adds a rule with the specified name and rule function to the rule set. +// If a rule with the same name already exists, it will not be added. +func (r *Rules) AddRule(name string, ruleFunc core.RuleFunc) { + if r.rules == nil { + r.rules = make(map[string]core.RuleFunc) + } + + if _, exists := r.rules[name]; !exists { + r.rules[name] = ruleFunc + r.ruleNameKeys = append(r.ruleNameKeys, name) + } +} + +// GetInner returns the internal rule map. +// If the map is not initialized, it returns an empty map. +func (r *Rules) GetInner() map[string]core.RuleFunc { + if r == nil { + return nil // impossible nonsense, hopefully + } + if r.rules == nil { + return make(map[string]core.RuleFunc) + } + return r.rules +} + +// RemoveRule removes a rule with the specified name from the rule set. +// If no rule with the specified name exists, it does nothing. +func (r *Rules) RemoveRule(name string) { + if r == nil { + return // impossible nonsense, hopefully + } + if r.rules != nil { + delete(r.rules, name) + } + + if len(r.ruleNameKeys) > 0 { + r.ruleNameKeys = slices.DeleteFunc(r.ruleNameKeys, func(s string) bool { + return s == name // delete the name rule key + }) + } +} + +// ReplaceRule replaces a rule with the specified name with a new rule function. +// If no rule with the specified name exists, it does nothing. +func (r *Rules) ReplaceRule(name string, ruleFunc core.RuleFunc) { + if r == nil { + return // impossible nonsense, hopefully + } + if r.rules == nil { + r.rules = make(map[string]core.RuleFunc) + } + if _, exists := r.rules[name]; exists { + r.rules[name] = ruleFunc + } +} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/scalar_leafs.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/scalar_leafs.go index 73a1e8967..e4f210d75 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/scalar_leafs.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/scalar_leafs.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var ScalarLeafsRule = Rule{ @@ -37,7 +37,3 @@ var ScalarLeafsRule = Rule{ }) }, } - -func init() { - AddRule(ScalarLeafsRule.Name, ScalarLeafsRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/single_field_subscriptions.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/single_field_subscriptions.go index 1498d8298..feed91d5c 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/single_field_subscriptions.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/single_field_subscriptions.go @@ -7,7 +7,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var SingleFieldSubscriptionsRule = Rule{ @@ -44,10 +44,6 @@ var SingleFieldSubscriptionsRule = Rule{ }, } -func init() { - AddRule(SingleFieldSubscriptionsRule.Name, SingleFieldSubscriptionsRule.RuleFunc) -} - type topField struct { name string position *ast.Position diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_argument_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_argument_names.go index b90cc6510..2ed1da2b3 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_argument_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_argument_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var UniqueArgumentNamesRule = Rule{ @@ -20,10 +20,6 @@ var UniqueArgumentNamesRule = Rule{ }, } -func init() { - AddRule(UniqueArgumentNamesRule.Name, UniqueArgumentNamesRule.RuleFunc) -} - func checkUniqueArgs(args ast.ArgumentList, addError AddErrFunc) { knownArgNames := map[string]int{} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_directives_per_location.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_directives_per_location.go index 4222f36ae..0f5770281 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_directives_per_location.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_directives_per_location.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var UniqueDirectivesPerLocationRule = Rule{ @@ -25,7 +25,3 @@ var UniqueDirectivesPerLocationRule = Rule{ }) }, } - -func init() { - AddRule(UniqueDirectivesPerLocationRule.Name, UniqueDirectivesPerLocationRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_fragment_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_fragment_names.go index aab8eeb4e..136b0fdb5 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_fragment_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_fragment_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var UniqueFragmentNamesRule = Rule{ @@ -23,7 +23,3 @@ var UniqueFragmentNamesRule = Rule{ }) }, } - -func init() { - AddRule(UniqueFragmentNamesRule.Name, UniqueFragmentNamesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_input_field_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_input_field_names.go index 250849344..41d8d667a 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_input_field_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_input_field_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var UniqueInputFieldNamesRule = Rule{ @@ -28,7 +28,3 @@ var UniqueInputFieldNamesRule = Rule{ }) }, } - -func init() { - AddRule(UniqueInputFieldNamesRule.Name, UniqueInputFieldNamesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_operation_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_operation_names.go index 6f1ec26ab..ae4c54eed 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_operation_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_operation_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var UniqueOperationNamesRule = Rule{ @@ -23,7 +23,3 @@ var UniqueOperationNamesRule = Rule{ }) }, } - -func init() { - AddRule(UniqueOperationNamesRule.Name, UniqueOperationNamesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_variable_names.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_variable_names.go index 6b037ed52..4d4a6a87f 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_variable_names.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/unique_variable_names.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var UniqueVariableNamesRule = Rule{ @@ -25,7 +25,3 @@ var UniqueVariableNamesRule = Rule{ }) }, } - -func init() { - AddRule(UniqueVariableNamesRule.Name, UniqueVariableNamesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/values_of_correct_type.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/values_of_correct_type.go index 01510b7b5..43c1a1bfb 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/values_of_correct_type.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/values_of_correct_type.go @@ -8,7 +8,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) func ruleFuncValuesOfCorrectType(observers *Events, addError AddErrFunc, disableSuggestion bool) { @@ -213,10 +213,6 @@ var ValuesOfCorrectTypeRuleWithoutSuggestions = Rule{ }, } -func init() { - AddRule(ValuesOfCorrectTypeRule.Name, ValuesOfCorrectTypeRule.RuleFunc) -} - func unexpectedTypeMessage(addError AddErrFunc, v *ast.Value) { addError( unexpectedTypeMessageOnly(v), diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_are_input_types.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_are_input_types.go index e1bf2b1f5..77f116bb5 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_are_input_types.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_are_input_types.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var VariablesAreInputTypesRule = Rule{ @@ -29,7 +29,3 @@ var VariablesAreInputTypesRule = Rule{ }) }, } - -func init() { - AddRule(VariablesAreInputTypesRule.Name, VariablesAreInputTypesRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_in_allowed_position.go b/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_in_allowed_position.go index f05ee687a..b2af7e192 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_in_allowed_position.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/rules/variables_in_allowed_position.go @@ -4,7 +4,7 @@ import ( "github.com/vektah/gqlparser/v2/ast" //nolint:staticcheck // Validator rules each use dot imports for convenience. - . "github.com/vektah/gqlparser/v2/validator" + . "github.com/vektah/gqlparser/v2/validator/core" ) var VariablesInAllowedPositionRule = Rule{ @@ -39,7 +39,3 @@ var VariablesInAllowedPositionRule = Rule{ }) }, } - -func init() { - AddRule(VariablesInAllowedPositionRule.Name, VariablesInAllowedPositionRule.RuleFunc) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/suggestionList.go b/vendor/github.com/vektah/gqlparser/v2/validator/suggestionList.go deleted file mode 100644 index f0bbc3278..000000000 --- a/vendor/github.com/vektah/gqlparser/v2/validator/suggestionList.go +++ /dev/null @@ -1,69 +0,0 @@ -package validator - -import ( - "math" - "sort" - "strings" - - "github.com/agnivade/levenshtein" -) - -// Given an invalid input string and a list of valid options, returns a filtered -// list of valid options sorted based on their similarity with the input. -func SuggestionList(input string, options []string) []string { - var results []string - optionsByDistance := map[string]int{} - - for _, option := range options { - distance := lexicalDistance(input, option) - threshold := calcThreshold(input) - if distance <= threshold { - results = append(results, option) - optionsByDistance[option] = distance - } - } - - sort.Slice(results, func(i, j int) bool { - return optionsByDistance[results[i]] < optionsByDistance[results[j]] - }) - return results -} - -func calcThreshold(a string) (threshold int) { - // the logic is copied from here - // https://github.com/graphql/graphql-js/blob/47bd8c8897c72d3efc17ecb1599a95cee6bac5e8/src/jsutils/suggestionList.ts#L14 - threshold = int(math.Floor(float64(len(a))*0.4) + 1) - - if threshold < 1 { - threshold = 1 - } - return -} - -// Computes the lexical distance between strings A and B. -// -// The "distance" between two strings is given by counting the minimum number -// of edits needed to transform string A into string B. An edit can be an -// insertion, deletion, or substitution of a single character, or a swap of two -// adjacent characters. -// -// Includes a custom alteration from Damerau-Levenshtein to treat case changes -// as a single edit which helps identify mis-cased values with an edit distance -// of 1. -// -// This distance can be useful for detecting typos in input or sorting -func lexicalDistance(a, b string) int { - if a == b { - return 0 - } - - a = strings.ToLower(a) - b = strings.ToLower(b) - - // Any case change counts as a single edit - if a == b { - return 1 - } - - return levenshtein.ComputeDistance(a, b) -} diff --git a/vendor/github.com/vektah/gqlparser/v2/validator/validator.go b/vendor/github.com/vektah/gqlparser/v2/validator/validator.go index 1b4040c2c..1214ed16e 100644 --- a/vendor/github.com/vektah/gqlparser/v2/validator/validator.go +++ b/vendor/github.com/vektah/gqlparser/v2/validator/validator.go @@ -1,22 +1,46 @@ package validator import ( + "sort" //nolint:staticcheck // bad, yeah . "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/vektah/gqlparser/v2/validator/core" + validatorrules "github.com/vektah/gqlparser/v2/validator/rules" ) -type AddErrFunc func(options ...ErrorOption) +type ( + AddErrFunc = core.AddErrFunc + RuleFunc = core.RuleFunc + Rule = core.Rule + Events = core.Events + ErrorOption = core.ErrorOption + Walker = core.Walker +) -type RuleFunc func(observers *Events, addError AddErrFunc) +var ( + Message = core.Message + QuotedOrList = core.QuotedOrList + OrList = core.OrList +) -type Rule struct { - Name string - RuleFunc RuleFunc +// Walk is an alias for core.Walk +func Walk(schema *Schema, document *QueryDocument, observers *Events) { + core.Walk(schema, document, observers) } var specifiedRules []Rule +func init() { + // Initialize specifiedRules with default rules + defaultRules := validatorrules.NewDefaultRules() + for name, ruleFunc := range defaultRules.GetInner() { + specifiedRules = append(specifiedRules, Rule{Name: name, RuleFunc: ruleFunc}) + // ensure initial default is in deterministic order + sort.Sort(core.NameSorter(specifiedRules)) + } +} + // AddRule adds a rule to the rule set. // ruleFunc is called once each time `Validate` is executed. func AddRule(name string, ruleFunc RuleFunc) { @@ -59,6 +83,7 @@ func ReplaceRule(name string, ruleFunc RuleFunc) { specifiedRules = result } +// Deprecated: use ValidateWithRules instead. func Validate(schema *Schema, doc *QueryDocument, rules ...Rule) gqlerror.List { if rules == nil { rules = specifiedRules @@ -74,7 +99,7 @@ func Validate(schema *Schema, doc *QueryDocument, rules ...Rule) gqlerror.List { if len(errs) > 0 { return errs } - observers := &Events{} + observers := &core.Events{} for i := range rules { rule := rules[i] rule.RuleFunc(observers, func(options ...ErrorOption) { @@ -91,3 +116,43 @@ func Validate(schema *Schema, doc *QueryDocument, rules ...Rule) gqlerror.List { Walk(schema, doc, observers) return errs } + +func ValidateWithRules(schema *Schema, doc *QueryDocument, rules *validatorrules.Rules) gqlerror.List { + if rules == nil { + rules = validatorrules.NewDefaultRules() + } + + var errs gqlerror.List + if schema == nil { + errs = append(errs, gqlerror.Errorf("cannot validate as Schema is nil")) + } + if doc == nil { + errs = append(errs, gqlerror.Errorf("cannot validate as QueryDocument is nil")) + } + if len(errs) > 0 { + return errs + } + observers := &core.Events{} + + var currentRules []Rule // nolint:prealloc // would require extra local refs for len + for name, ruleFunc := range rules.GetInner() { + currentRules = append(currentRules, Rule{Name: name, RuleFunc: ruleFunc}) + // ensure deterministic order evaluation + sort.Sort(core.NameSorter(currentRules)) + } + + for _, currentRule := range currentRules { + currentRule.RuleFunc(observers, func(options ...ErrorOption) { + err := &gqlerror.Error{ + Rule: currentRule.Name, + } + for _, o := range options { + o(err) + } + errs = append(errs, err) + }) + } + + Walk(schema, doc, observers) + return errs +} diff --git a/vendor/golang.org/x/crypto/ssh/agent/client.go b/vendor/golang.org/x/crypto/ssh/agent/client.go index 106708d28..37525e1a1 100644 --- a/vendor/golang.org/x/crypto/ssh/agent/client.go +++ b/vendor/golang.org/x/crypto/ssh/agent/client.go @@ -555,7 +555,7 @@ func (c *client) insertKey(s interface{}, comment string, constraints []byte) er }) case *dsa.PrivateKey: req = ssh.Marshal(dsaKeyMsg{ - Type: ssh.KeyAlgoDSA, + Type: ssh.InsecureKeyAlgoDSA, P: k.P, Q: k.Q, G: k.G, @@ -803,16 +803,16 @@ var _ ssh.AlgorithmSigner = &agentKeyringSigner{} // // This map must be kept in sync with the one in certs.go. var certKeyAlgoNames = map[string]string{ - ssh.CertAlgoRSAv01: ssh.KeyAlgoRSA, - ssh.CertAlgoRSASHA256v01: ssh.KeyAlgoRSASHA256, - ssh.CertAlgoRSASHA512v01: ssh.KeyAlgoRSASHA512, - ssh.CertAlgoDSAv01: ssh.KeyAlgoDSA, - ssh.CertAlgoECDSA256v01: ssh.KeyAlgoECDSA256, - ssh.CertAlgoECDSA384v01: ssh.KeyAlgoECDSA384, - ssh.CertAlgoECDSA521v01: ssh.KeyAlgoECDSA521, - ssh.CertAlgoSKECDSA256v01: ssh.KeyAlgoSKECDSA256, - ssh.CertAlgoED25519v01: ssh.KeyAlgoED25519, - ssh.CertAlgoSKED25519v01: ssh.KeyAlgoSKED25519, + ssh.CertAlgoRSAv01: ssh.KeyAlgoRSA, + ssh.CertAlgoRSASHA256v01: ssh.KeyAlgoRSASHA256, + ssh.CertAlgoRSASHA512v01: ssh.KeyAlgoRSASHA512, + ssh.InsecureCertAlgoDSAv01: ssh.InsecureKeyAlgoDSA, + ssh.CertAlgoECDSA256v01: ssh.KeyAlgoECDSA256, + ssh.CertAlgoECDSA384v01: ssh.KeyAlgoECDSA384, + ssh.CertAlgoECDSA521v01: ssh.KeyAlgoECDSA521, + ssh.CertAlgoSKECDSA256v01: ssh.KeyAlgoSKECDSA256, + ssh.CertAlgoED25519v01: ssh.KeyAlgoED25519, + ssh.CertAlgoSKED25519v01: ssh.KeyAlgoSKED25519, } // underlyingAlgo returns the signature algorithm associated with algo (which is diff --git a/vendor/golang.org/x/crypto/ssh/agent/server.go b/vendor/golang.org/x/crypto/ssh/agent/server.go index e35ca7ce3..88ce4da6c 100644 --- a/vendor/golang.org/x/crypto/ssh/agent/server.go +++ b/vendor/golang.org/x/crypto/ssh/agent/server.go @@ -506,7 +506,7 @@ func (s *server) insertIdentity(req []byte) error { switch record.Type { case ssh.KeyAlgoRSA: addedKey, err = parseRSAKey(req) - case ssh.KeyAlgoDSA: + case ssh.InsecureKeyAlgoDSA: addedKey, err = parseDSAKey(req) case ssh.KeyAlgoECDSA256, ssh.KeyAlgoECDSA384, ssh.KeyAlgoECDSA521: addedKey, err = parseECDSAKey(req) @@ -514,7 +514,7 @@ func (s *server) insertIdentity(req []byte) error { addedKey, err = parseEd25519Key(req) case ssh.CertAlgoRSAv01: addedKey, err = parseRSACert(req) - case ssh.CertAlgoDSAv01: + case ssh.InsecureCertAlgoDSAv01: addedKey, err = parseDSACert(req) case ssh.CertAlgoECDSA256v01, ssh.CertAlgoECDSA384v01, ssh.CertAlgoECDSA521v01: addedKey, err = parseECDSACert(req) diff --git a/vendor/golang.org/x/crypto/ssh/certs.go b/vendor/golang.org/x/crypto/ssh/certs.go index 27d0e14aa..a3dc629c6 100644 --- a/vendor/golang.org/x/crypto/ssh/certs.go +++ b/vendor/golang.org/x/crypto/ssh/certs.go @@ -20,14 +20,19 @@ import ( // returned by MultiAlgorithmSigner and don't appear in the Signature.Format // field. const ( - CertAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com" - CertAlgoDSAv01 = "ssh-dss-cert-v01@openssh.com" - CertAlgoECDSA256v01 = "ecdsa-sha2-nistp256-cert-v01@openssh.com" - CertAlgoECDSA384v01 = "ecdsa-sha2-nistp384-cert-v01@openssh.com" - CertAlgoECDSA521v01 = "ecdsa-sha2-nistp521-cert-v01@openssh.com" - CertAlgoSKECDSA256v01 = "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com" - CertAlgoED25519v01 = "ssh-ed25519-cert-v01@openssh.com" - CertAlgoSKED25519v01 = "sk-ssh-ed25519-cert-v01@openssh.com" + CertAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com" + // Deprecated: DSA is only supported at insecure key sizes, and was removed + // from major implementations. + CertAlgoDSAv01 = InsecureCertAlgoDSAv01 + // Deprecated: DSA is only supported at insecure key sizes, and was removed + // from major implementations. + InsecureCertAlgoDSAv01 = "ssh-dss-cert-v01@openssh.com" + CertAlgoECDSA256v01 = "ecdsa-sha2-nistp256-cert-v01@openssh.com" + CertAlgoECDSA384v01 = "ecdsa-sha2-nistp384-cert-v01@openssh.com" + CertAlgoECDSA521v01 = "ecdsa-sha2-nistp521-cert-v01@openssh.com" + CertAlgoSKECDSA256v01 = "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com" + CertAlgoED25519v01 = "ssh-ed25519-cert-v01@openssh.com" + CertAlgoSKED25519v01 = "sk-ssh-ed25519-cert-v01@openssh.com" // CertAlgoRSASHA256v01 and CertAlgoRSASHA512v01 can't appear as a // Certificate.Type (or PublicKey.Type), but only in @@ -485,16 +490,16 @@ func (c *Certificate) SignCert(rand io.Reader, authority Signer) error { // // This map must be kept in sync with the one in agent/client.go. var certKeyAlgoNames = map[string]string{ - CertAlgoRSAv01: KeyAlgoRSA, - CertAlgoRSASHA256v01: KeyAlgoRSASHA256, - CertAlgoRSASHA512v01: KeyAlgoRSASHA512, - CertAlgoDSAv01: KeyAlgoDSA, - CertAlgoECDSA256v01: KeyAlgoECDSA256, - CertAlgoECDSA384v01: KeyAlgoECDSA384, - CertAlgoECDSA521v01: KeyAlgoECDSA521, - CertAlgoSKECDSA256v01: KeyAlgoSKECDSA256, - CertAlgoED25519v01: KeyAlgoED25519, - CertAlgoSKED25519v01: KeyAlgoSKED25519, + CertAlgoRSAv01: KeyAlgoRSA, + CertAlgoRSASHA256v01: KeyAlgoRSASHA256, + CertAlgoRSASHA512v01: KeyAlgoRSASHA512, + InsecureCertAlgoDSAv01: InsecureKeyAlgoDSA, + CertAlgoECDSA256v01: KeyAlgoECDSA256, + CertAlgoECDSA384v01: KeyAlgoECDSA384, + CertAlgoECDSA521v01: KeyAlgoECDSA521, + CertAlgoSKECDSA256v01: KeyAlgoSKECDSA256, + CertAlgoED25519v01: KeyAlgoED25519, + CertAlgoSKED25519v01: KeyAlgoSKED25519, } // underlyingAlgo returns the signature algorithm associated with algo (which is diff --git a/vendor/golang.org/x/crypto/ssh/cipher.go b/vendor/golang.org/x/crypto/ssh/cipher.go index 741e984f3..6a5b582aa 100644 --- a/vendor/golang.org/x/crypto/ssh/cipher.go +++ b/vendor/golang.org/x/crypto/ssh/cipher.go @@ -58,11 +58,11 @@ func newRC4(key, iv []byte) (cipher.Stream, error) { type cipherMode struct { keySize int ivSize int - create func(key, iv []byte, macKey []byte, algs directionAlgorithms) (packetCipher, error) + create func(key, iv []byte, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) } -func streamCipherMode(skip int, createFunc func(key, iv []byte) (cipher.Stream, error)) func(key, iv []byte, macKey []byte, algs directionAlgorithms) (packetCipher, error) { - return func(key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) { +func streamCipherMode(skip int, createFunc func(key, iv []byte) (cipher.Stream, error)) func(key, iv []byte, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) { + return func(key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) { stream, err := createFunc(key, iv) if err != nil { return nil, err @@ -98,36 +98,36 @@ func streamCipherMode(skip int, createFunc func(key, iv []byte) (cipher.Stream, var cipherModes = map[string]*cipherMode{ // Ciphers from RFC 4344, which introduced many CTR-based ciphers. Algorithms // are defined in the order specified in the RFC. - "aes128-ctr": {16, aes.BlockSize, streamCipherMode(0, newAESCTR)}, - "aes192-ctr": {24, aes.BlockSize, streamCipherMode(0, newAESCTR)}, - "aes256-ctr": {32, aes.BlockSize, streamCipherMode(0, newAESCTR)}, + CipherAES128CTR: {16, aes.BlockSize, streamCipherMode(0, newAESCTR)}, + CipherAES192CTR: {24, aes.BlockSize, streamCipherMode(0, newAESCTR)}, + CipherAES256CTR: {32, aes.BlockSize, streamCipherMode(0, newAESCTR)}, // Ciphers from RFC 4345, which introduces security-improved arcfour ciphers. // They are defined in the order specified in the RFC. - "arcfour128": {16, 0, streamCipherMode(1536, newRC4)}, - "arcfour256": {32, 0, streamCipherMode(1536, newRC4)}, + InsecureCipherRC4128: {16, 0, streamCipherMode(1536, newRC4)}, + InsecureCipherRC4256: {32, 0, streamCipherMode(1536, newRC4)}, // Cipher defined in RFC 4253, which describes SSH Transport Layer Protocol. // Note that this cipher is not safe, as stated in RFC 4253: "Arcfour (and // RC4) has problems with weak keys, and should be used with caution." // RFC 4345 introduces improved versions of Arcfour. - "arcfour": {16, 0, streamCipherMode(0, newRC4)}, + InsecureCipherRC4: {16, 0, streamCipherMode(0, newRC4)}, // AEAD ciphers - gcm128CipherID: {16, 12, newGCMCipher}, - gcm256CipherID: {32, 12, newGCMCipher}, - chacha20Poly1305ID: {64, 0, newChaCha20Cipher}, + CipherAES128GCM: {16, 12, newGCMCipher}, + CipherAES256GCM: {32, 12, newGCMCipher}, + CipherChaCha20Poly1305: {64, 0, newChaCha20Cipher}, // CBC mode is insecure and so is not included in the default config. // (See https://www.ieee-security.org/TC/SP2013/papers/4977a526.pdf). If absolutely // needed, it's possible to specify a custom Config to enable it. // You should expect that an active attacker can recover plaintext if // you do. - aes128cbcID: {16, aes.BlockSize, newAESCBCCipher}, + InsecureCipherAES128CBC: {16, aes.BlockSize, newAESCBCCipher}, // 3des-cbc is insecure and is not included in the default // config. - tripledescbcID: {24, des.BlockSize, newTripleDESCBCCipher}, + InsecureCipherTripleDESCBC: {24, des.BlockSize, newTripleDESCBCCipher}, } // prefixLen is the length of the packet prefix that contains the packet length @@ -307,7 +307,7 @@ type gcmCipher struct { buf []byte } -func newGCMCipher(key, iv, unusedMacKey []byte, unusedAlgs directionAlgorithms) (packetCipher, error) { +func newGCMCipher(key, iv, unusedMacKey []byte, unusedAlgs DirectionAlgorithms) (packetCipher, error) { c, err := aes.NewCipher(key) if err != nil { return nil, err @@ -429,7 +429,7 @@ type cbcCipher struct { oracleCamouflage uint32 } -func newCBCCipher(c cipher.Block, key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) { +func newCBCCipher(c cipher.Block, key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) { cbc := &cbcCipher{ mac: macModes[algs.MAC].new(macKey), decrypter: cipher.NewCBCDecrypter(c, iv), @@ -443,7 +443,7 @@ func newCBCCipher(c cipher.Block, key, iv, macKey []byte, algs directionAlgorith return cbc, nil } -func newAESCBCCipher(key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) { +func newAESCBCCipher(key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) { c, err := aes.NewCipher(key) if err != nil { return nil, err @@ -457,7 +457,7 @@ func newAESCBCCipher(key, iv, macKey []byte, algs directionAlgorithms) (packetCi return cbc, nil } -func newTripleDESCBCCipher(key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) { +func newTripleDESCBCCipher(key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) { c, err := des.NewTripleDESCipher(key) if err != nil { return nil, err @@ -635,8 +635,6 @@ func (c *cbcCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader return nil } -const chacha20Poly1305ID = "chacha20-poly1305@openssh.com" - // chacha20Poly1305Cipher implements the chacha20-poly1305@openssh.com // AEAD, which is described here: // @@ -650,7 +648,7 @@ type chacha20Poly1305Cipher struct { buf []byte } -func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs directionAlgorithms) (packetCipher, error) { +func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs DirectionAlgorithms) (packetCipher, error) { if len(key) != 64 { panic(len(key)) } diff --git a/vendor/golang.org/x/crypto/ssh/client.go b/vendor/golang.org/x/crypto/ssh/client.go index fd8c49749..33079789b 100644 --- a/vendor/golang.org/x/crypto/ssh/client.go +++ b/vendor/golang.org/x/crypto/ssh/client.go @@ -110,6 +110,7 @@ func (c *connection) clientHandshake(dialAddress string, config *ClientConfig) e } c.sessionID = c.transport.getSessionID() + c.algorithms = c.transport.getAlgorithms() return c.clientAuthenticate(config) } diff --git a/vendor/golang.org/x/crypto/ssh/common.go b/vendor/golang.org/x/crypto/ssh/common.go index 7e9c2cbc6..0415d3396 100644 --- a/vendor/golang.org/x/crypto/ssh/common.go +++ b/vendor/golang.org/x/crypto/ssh/common.go @@ -10,6 +10,7 @@ import ( "fmt" "io" "math" + "slices" "sync" _ "crypto/sha1" @@ -24,69 +25,258 @@ const ( serviceSSH = "ssh-connection" ) -// supportedCiphers lists ciphers we support but might not recommend. -var supportedCiphers = []string{ - "aes128-ctr", "aes192-ctr", "aes256-ctr", - "aes128-gcm@openssh.com", gcm256CipherID, - chacha20Poly1305ID, - "arcfour256", "arcfour128", "arcfour", - aes128cbcID, - tripledescbcID, -} - -// preferredCiphers specifies the default preference for ciphers. -var preferredCiphers = []string{ - "aes128-gcm@openssh.com", gcm256CipherID, - chacha20Poly1305ID, - "aes128-ctr", "aes192-ctr", "aes256-ctr", -} - -// supportedKexAlgos specifies the supported key-exchange algorithms in -// preference order. -var supportedKexAlgos = []string{ - kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH, - // P384 and P521 are not constant-time yet, but since we don't - // reuse ephemeral keys, using them for ECDH should be OK. - kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521, - kexAlgoDH14SHA256, kexAlgoDH16SHA512, kexAlgoDH14SHA1, - kexAlgoDH1SHA1, -} +// The ciphers currently or previously implemented by this library, to use in +// [Config.Ciphers]. For a list, see the [Algorithms.Ciphers] returned by +// [SupportedAlgorithms] or [InsecureAlgorithms]. +const ( + CipherAES128GCM = "aes128-gcm@openssh.com" + CipherAES256GCM = "aes256-gcm@openssh.com" + CipherChaCha20Poly1305 = "chacha20-poly1305@openssh.com" + CipherAES128CTR = "aes128-ctr" + CipherAES192CTR = "aes192-ctr" + CipherAES256CTR = "aes256-ctr" + InsecureCipherAES128CBC = "aes128-cbc" + InsecureCipherTripleDESCBC = "3des-cbc" + InsecureCipherRC4 = "arcfour" + InsecureCipherRC4128 = "arcfour128" + InsecureCipherRC4256 = "arcfour256" +) -// serverForbiddenKexAlgos contains key exchange algorithms, that are forbidden -// for the server half. -var serverForbiddenKexAlgos = map[string]struct{}{ - kexAlgoDHGEXSHA1: {}, // server half implementation is only minimal to satisfy the automated tests - kexAlgoDHGEXSHA256: {}, // server half implementation is only minimal to satisfy the automated tests -} +// The key exchanges currently or previously implemented by this library, to use +// in [Config.KeyExchanges]. For a list, see the +// [Algorithms.KeyExchanges] returned by [SupportedAlgorithms] or +// [InsecureAlgorithms]. +const ( + InsecureKeyExchangeDH1SHA1 = "diffie-hellman-group1-sha1" + InsecureKeyExchangeDH14SHA1 = "diffie-hellman-group14-sha1" + KeyExchangeDH14SHA256 = "diffie-hellman-group14-sha256" + KeyExchangeDH16SHA512 = "diffie-hellman-group16-sha512" + KeyExchangeECDHP256 = "ecdh-sha2-nistp256" + KeyExchangeECDHP384 = "ecdh-sha2-nistp384" + KeyExchangeECDHP521 = "ecdh-sha2-nistp521" + KeyExchangeCurve25519 = "curve25519-sha256" + InsecureKeyExchangeDHGEXSHA1 = "diffie-hellman-group-exchange-sha1" + KeyExchangeDHGEXSHA256 = "diffie-hellman-group-exchange-sha256" + // KeyExchangeMLKEM768X25519 is supported from Go 1.24. + KeyExchangeMLKEM768X25519 = "mlkem768x25519-sha256" + + // An alias for KeyExchangeCurve25519SHA256. This kex ID will be added if + // KeyExchangeCurve25519SHA256 is requested for backward compatibility with + // OpenSSH versions up to 7.2. + keyExchangeCurve25519LibSSH = "curve25519-sha256@libssh.org" +) -// preferredKexAlgos specifies the default preference for key-exchange -// algorithms in preference order. The diffie-hellman-group16-sha512 algorithm -// is disabled by default because it is a bit slower than the others. -var preferredKexAlgos = []string{ - kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH, - kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521, - kexAlgoDH14SHA256, kexAlgoDH14SHA1, -} +// The message authentication code (MAC) currently or previously implemented by +// this library, to use in [Config.MACs]. For a list, see the +// [Algorithms.MACs] returned by [SupportedAlgorithms] or +// [InsecureAlgorithms]. +const ( + HMACSHA256ETM = "hmac-sha2-256-etm@openssh.com" + HMACSHA512ETM = "hmac-sha2-512-etm@openssh.com" + HMACSHA256 = "hmac-sha2-256" + HMACSHA512 = "hmac-sha2-512" + HMACSHA1 = "hmac-sha1" + InsecureHMACSHA196 = "hmac-sha1-96" +) -// supportedHostKeyAlgos specifies the supported host-key algorithms (i.e. methods -// of authenticating servers) in preference order. -var supportedHostKeyAlgos = []string{ - CertAlgoRSASHA256v01, CertAlgoRSASHA512v01, - CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, - CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoED25519v01, +var ( + // supportedKexAlgos specifies key-exchange algorithms implemented by this + // package in preference order, excluding those with security issues. + supportedKexAlgos = []string{ + KeyExchangeCurve25519, + KeyExchangeECDHP256, + KeyExchangeECDHP384, + KeyExchangeECDHP521, + KeyExchangeDH14SHA256, + KeyExchangeDH16SHA512, + KeyExchangeDHGEXSHA256, + } + // defaultKexAlgos specifies the default preference for key-exchange + // algorithms in preference order. + defaultKexAlgos = []string{ + KeyExchangeCurve25519, + KeyExchangeECDHP256, + KeyExchangeECDHP384, + KeyExchangeECDHP521, + KeyExchangeDH14SHA256, + InsecureKeyExchangeDH14SHA1, + } + // insecureKexAlgos specifies key-exchange algorithms implemented by this + // package and which have security issues. + insecureKexAlgos = []string{ + InsecureKeyExchangeDH14SHA1, + InsecureKeyExchangeDH1SHA1, + InsecureKeyExchangeDHGEXSHA1, + } + // supportedCiphers specifies cipher algorithms implemented by this package + // in preference order, excluding those with security issues. + supportedCiphers = []string{ + CipherAES128GCM, + CipherAES256GCM, + CipherChaCha20Poly1305, + CipherAES128CTR, + CipherAES192CTR, + CipherAES256CTR, + } + // defaultCiphers specifies the default preference for ciphers algorithms + // in preference order. + defaultCiphers = supportedCiphers + // insecureCiphers specifies cipher algorithms implemented by this + // package and which have security issues. + insecureCiphers = []string{ + InsecureCipherAES128CBC, + InsecureCipherTripleDESCBC, + InsecureCipherRC4256, + InsecureCipherRC4128, + InsecureCipherRC4, + } + // supportedMACs specifies MAC algorithms implemented by this package in + // preference order, excluding those with security issues. + supportedMACs = []string{ + HMACSHA256ETM, + HMACSHA512ETM, + HMACSHA256, + HMACSHA512, + HMACSHA1, + } + // defaultMACs specifies the default preference for MAC algorithms in + // preference order. + defaultMACs = []string{ + HMACSHA256ETM, + HMACSHA512ETM, + HMACSHA256, + HMACSHA512, + HMACSHA1, + InsecureHMACSHA196, + } + // insecureMACs specifies MAC algorithms implemented by this + // package and which have security issues. + insecureMACs = []string{ + InsecureHMACSHA196, + } + // supportedHostKeyAlgos specifies the supported host-key algorithms (i.e. + // methods of authenticating servers) implemented by this package in + // preference order, excluding those with security issues. + supportedHostKeyAlgos = []string{ + CertAlgoRSASHA256v01, + CertAlgoRSASHA512v01, + CertAlgoECDSA256v01, + CertAlgoECDSA384v01, + CertAlgoECDSA521v01, + CertAlgoED25519v01, + KeyAlgoRSASHA256, + KeyAlgoRSASHA512, + KeyAlgoECDSA256, + KeyAlgoECDSA384, + KeyAlgoECDSA521, + KeyAlgoED25519, + } + // defaultHostKeyAlgos specifies the default preference for host-key + // algorithms in preference order. + defaultHostKeyAlgos = []string{ + CertAlgoRSASHA256v01, + CertAlgoRSASHA512v01, + CertAlgoRSAv01, + InsecureCertAlgoDSAv01, + CertAlgoECDSA256v01, + CertAlgoECDSA384v01, + CertAlgoECDSA521v01, + CertAlgoED25519v01, + KeyAlgoECDSA256, + KeyAlgoECDSA384, + KeyAlgoECDSA521, + KeyAlgoRSASHA256, + KeyAlgoRSASHA512, + KeyAlgoRSA, + InsecureKeyAlgoDSA, + KeyAlgoED25519, + } + // insecureHostKeyAlgos specifies host-key algorithms implemented by this + // package and which have security issues. + insecureHostKeyAlgos = []string{ + KeyAlgoRSA, + InsecureKeyAlgoDSA, + CertAlgoRSAv01, + InsecureCertAlgoDSAv01, + } + // supportedPubKeyAuthAlgos specifies the supported client public key + // authentication algorithms. Note that this doesn't include certificate + // types since those use the underlying algorithm. Order is irrelevant. + supportedPubKeyAuthAlgos = []string{ + KeyAlgoED25519, + KeyAlgoSKED25519, + KeyAlgoSKECDSA256, + KeyAlgoECDSA256, + KeyAlgoECDSA384, + KeyAlgoECDSA521, + KeyAlgoRSASHA256, + KeyAlgoRSASHA512, + } - KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521, - KeyAlgoRSASHA256, KeyAlgoRSASHA512, - KeyAlgoRSA, KeyAlgoDSA, + // defaultPubKeyAuthAlgos specifies the preferred client public key + // authentication algorithms. This list is sent to the client if it supports + // the server-sig-algs extension. Order is irrelevant. + defaultPubKeyAuthAlgos = []string{ + KeyAlgoED25519, + KeyAlgoSKED25519, + KeyAlgoSKECDSA256, + KeyAlgoECDSA256, + KeyAlgoECDSA384, + KeyAlgoECDSA521, + KeyAlgoRSASHA256, + KeyAlgoRSASHA512, + KeyAlgoRSA, + InsecureKeyAlgoDSA, + } + // insecurePubKeyAuthAlgos specifies client public key authentication + // algorithms implemented by this package and which have security issues. + insecurePubKeyAuthAlgos = []string{ + KeyAlgoRSA, + InsecureKeyAlgoDSA, + } +) - KeyAlgoED25519, +// NegotiatedAlgorithms defines algorithms negotiated between client and server. +type NegotiatedAlgorithms struct { + KeyExchange string + HostKey string + Read DirectionAlgorithms + Write DirectionAlgorithms +} + +// Algorithms defines a set of algorithms that can be configured in the client +// or server config for negotiation during a handshake. +type Algorithms struct { + KeyExchanges []string + Ciphers []string + MACs []string + HostKeys []string + PublicKeyAuths []string +} + +// SupportedAlgorithms returns algorithms currently implemented by this package, +// excluding those with security issues, which are returned by +// InsecureAlgorithms. The algorithms listed here are in preference order. +func SupportedAlgorithms() Algorithms { + return Algorithms{ + Ciphers: slices.Clone(supportedCiphers), + MACs: slices.Clone(supportedMACs), + KeyExchanges: slices.Clone(supportedKexAlgos), + HostKeys: slices.Clone(supportedHostKeyAlgos), + PublicKeyAuths: slices.Clone(supportedPubKeyAuthAlgos), + } } -// supportedMACs specifies a default set of MAC algorithms in preference order. -// This is based on RFC 4253, section 6.4, but with hmac-md5 variants removed -// because they have reached the end of their useful life. -var supportedMACs = []string{ - "hmac-sha2-256-etm@openssh.com", "hmac-sha2-512-etm@openssh.com", "hmac-sha2-256", "hmac-sha2-512", "hmac-sha1", "hmac-sha1-96", +// InsecureAlgorithms returns algorithms currently implemented by this package +// and which have security issues. +func InsecureAlgorithms() Algorithms { + return Algorithms{ + KeyExchanges: slices.Clone(insecureKexAlgos), + Ciphers: slices.Clone(insecureCiphers), + MACs: slices.Clone(insecureMACs), + HostKeys: slices.Clone(insecureHostKeyAlgos), + PublicKeyAuths: slices.Clone(insecurePubKeyAuthAlgos), + } } var supportedCompressions = []string{compressionNone} @@ -94,13 +284,13 @@ var supportedCompressions = []string{compressionNone} // hashFuncs keeps the mapping of supported signature algorithms to their // respective hashes needed for signing and verification. var hashFuncs = map[string]crypto.Hash{ - KeyAlgoRSA: crypto.SHA1, - KeyAlgoRSASHA256: crypto.SHA256, - KeyAlgoRSASHA512: crypto.SHA512, - KeyAlgoDSA: crypto.SHA1, - KeyAlgoECDSA256: crypto.SHA256, - KeyAlgoECDSA384: crypto.SHA384, - KeyAlgoECDSA521: crypto.SHA512, + KeyAlgoRSA: crypto.SHA1, + KeyAlgoRSASHA256: crypto.SHA256, + KeyAlgoRSASHA512: crypto.SHA512, + InsecureKeyAlgoDSA: crypto.SHA1, + KeyAlgoECDSA256: crypto.SHA256, + KeyAlgoECDSA384: crypto.SHA384, + KeyAlgoECDSA521: crypto.SHA512, // KeyAlgoED25519 doesn't pre-hash. KeyAlgoSKECDSA256: crypto.SHA256, KeyAlgoSKED25519: crypto.SHA256, @@ -135,18 +325,6 @@ func isRSACert(algo string) bool { return isRSA(algo) } -// supportedPubKeyAuthAlgos specifies the supported client public key -// authentication algorithms. Note that this doesn't include certificate types -// since those use the underlying algorithm. This list is sent to the client if -// it supports the server-sig-algs extension. Order is irrelevant. -var supportedPubKeyAuthAlgos = []string{ - KeyAlgoED25519, - KeyAlgoSKED25519, KeyAlgoSKECDSA256, - KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521, - KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoRSA, - KeyAlgoDSA, -} - // unexpectedMessageError results when the SSH message that we received didn't // match what we wanted. func unexpectedMessageError(expected, got uint8) error { @@ -169,20 +347,21 @@ func findCommon(what string, client []string, server []string) (common string, e return "", fmt.Errorf("ssh: no common algorithm for %s; client offered: %v, server offered: %v", what, client, server) } -// directionAlgorithms records algorithm choices in one direction (either read or write) -type directionAlgorithms struct { +// DirectionAlgorithms defines the algorithms negotiated in one direction +// (either read or write). +type DirectionAlgorithms struct { Cipher string MAC string - Compression string + compression string } // rekeyBytes returns a rekeying intervals in bytes. -func (a *directionAlgorithms) rekeyBytes() int64 { +func (a *DirectionAlgorithms) rekeyBytes() int64 { // According to RFC 4344 block ciphers should rekey after // 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is // 128. switch a.Cipher { - case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcm128CipherID, gcm256CipherID, aes128cbcID: + case CipherAES128CTR, CipherAES192CTR, CipherAES256CTR, CipherAES128GCM, CipherAES256GCM, InsecureCipherAES128CBC: return 16 * (1 << 32) } @@ -192,32 +371,25 @@ func (a *directionAlgorithms) rekeyBytes() int64 { } var aeadCiphers = map[string]bool{ - gcm128CipherID: true, - gcm256CipherID: true, - chacha20Poly1305ID: true, -} - -type algorithms struct { - kex string - hostKey string - w directionAlgorithms - r directionAlgorithms + CipherAES128GCM: true, + CipherAES256GCM: true, + CipherChaCha20Poly1305: true, } -func findAgreedAlgorithms(isClient bool, clientKexInit, serverKexInit *kexInitMsg) (algs *algorithms, err error) { - result := &algorithms{} +func findAgreedAlgorithms(isClient bool, clientKexInit, serverKexInit *kexInitMsg) (algs *NegotiatedAlgorithms, err error) { + result := &NegotiatedAlgorithms{} - result.kex, err = findCommon("key exchange", clientKexInit.KexAlgos, serverKexInit.KexAlgos) + result.KeyExchange, err = findCommon("key exchange", clientKexInit.KexAlgos, serverKexInit.KexAlgos) if err != nil { return } - result.hostKey, err = findCommon("host key", clientKexInit.ServerHostKeyAlgos, serverKexInit.ServerHostKeyAlgos) + result.HostKey, err = findCommon("host key", clientKexInit.ServerHostKeyAlgos, serverKexInit.ServerHostKeyAlgos) if err != nil { return } - stoc, ctos := &result.w, &result.r + stoc, ctos := &result.Write, &result.Read if isClient { ctos, stoc = stoc, ctos } @@ -246,12 +418,12 @@ func findAgreedAlgorithms(isClient bool, clientKexInit, serverKexInit *kexInitMs } } - ctos.Compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer) + ctos.compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer) if err != nil { return } - stoc.Compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient) + stoc.compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient) if err != nil { return } @@ -297,7 +469,7 @@ func (c *Config) SetDefaults() { c.Rand = rand.Reader } if c.Ciphers == nil { - c.Ciphers = preferredCiphers + c.Ciphers = defaultCiphers } var ciphers []string for _, c := range c.Ciphers { @@ -309,19 +481,22 @@ func (c *Config) SetDefaults() { c.Ciphers = ciphers if c.KeyExchanges == nil { - c.KeyExchanges = preferredKexAlgos + c.KeyExchanges = defaultKexAlgos } var kexs []string for _, k := range c.KeyExchanges { if kexAlgoMap[k] != nil { // Ignore the KEX if we have no kexAlgoMap definition. kexs = append(kexs, k) + if k == KeyExchangeCurve25519 && !contains(c.KeyExchanges, keyExchangeCurve25519LibSSH) { + kexs = append(kexs, keyExchangeCurve25519LibSSH) + } } } c.KeyExchanges = kexs if c.MACs == nil { - c.MACs = supportedMACs + c.MACs = defaultMACs } var macs []string for _, m := range c.MACs { diff --git a/vendor/golang.org/x/crypto/ssh/connection.go b/vendor/golang.org/x/crypto/ssh/connection.go index 8f345ee92..613a71a7b 100644 --- a/vendor/golang.org/x/crypto/ssh/connection.go +++ b/vendor/golang.org/x/crypto/ssh/connection.go @@ -74,6 +74,13 @@ type Conn interface { // Disconnect } +// AlgorithmsConnMetadata is a ConnMetadata that can return the algorithms +// negotiated between client and server. +type AlgorithmsConnMetadata interface { + ConnMetadata + Algorithms() NegotiatedAlgorithms +} + // DiscardRequests consumes and rejects all requests from the // passed-in channel. func DiscardRequests(in <-chan *Request) { @@ -106,6 +113,7 @@ type sshConn struct { sessionID []byte clientVersion []byte serverVersion []byte + algorithms NegotiatedAlgorithms } func dup(src []byte) []byte { @@ -141,3 +149,7 @@ func (c *sshConn) ClientVersion() []byte { func (c *sshConn) ServerVersion() []byte { return dup(c.serverVersion) } + +func (c *sshConn) Algorithms() NegotiatedAlgorithms { + return c.algorithms +} diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go index b6bf546b4..a90bfe331 100644 --- a/vendor/golang.org/x/crypto/ssh/handshake.go +++ b/vendor/golang.org/x/crypto/ssh/handshake.go @@ -38,7 +38,7 @@ type keyingTransport interface { // prepareKeyChange sets up a key change. The key change for a // direction will be effected if a msgNewKeys message is sent // or received. - prepareKeyChange(*algorithms, *kexResult) error + prepareKeyChange(*NegotiatedAlgorithms, *kexResult) error // setStrictMode sets the strict KEX mode, notably triggering // sequence number resets on sending or receiving msgNewKeys. @@ -115,7 +115,7 @@ type handshakeTransport struct { bannerCallback BannerCallback // Algorithms agreed in the last key exchange. - algorithms *algorithms + algorithms *NegotiatedAlgorithms // Counters exclusively owned by readLoop. readPacketsLeft uint32 @@ -164,7 +164,7 @@ func newClientTransport(conn keyingTransport, clientVersion, serverVersion []byt if config.HostKeyAlgorithms != nil { t.hostKeyAlgorithms = config.HostKeyAlgorithms } else { - t.hostKeyAlgorithms = supportedHostKeyAlgos + t.hostKeyAlgorithms = defaultHostKeyAlgos } go t.readLoop() go t.kexLoop() @@ -184,6 +184,10 @@ func (t *handshakeTransport) getSessionID() []byte { return t.sessionID } +func (t *handshakeTransport) getAlgorithms() NegotiatedAlgorithms { + return *t.algorithms +} + // waitSession waits for the session to be established. This should be // the first thing to call after instantiating handshakeTransport. func (t *handshakeTransport) waitSession() error { @@ -290,7 +294,7 @@ func (t *handshakeTransport) resetWriteThresholds() { if t.config.RekeyThreshold > 0 { t.writeBytesLeft = int64(t.config.RekeyThreshold) } else if t.algorithms != nil { - t.writeBytesLeft = t.algorithms.w.rekeyBytes() + t.writeBytesLeft = t.algorithms.Write.rekeyBytes() } else { t.writeBytesLeft = 1 << 30 } @@ -407,7 +411,7 @@ func (t *handshakeTransport) resetReadThresholds() { if t.config.RekeyThreshold > 0 { t.readBytesLeft = int64(t.config.RekeyThreshold) } else if t.algorithms != nil { - t.readBytesLeft = t.algorithms.r.rekeyBytes() + t.readBytesLeft = t.algorithms.Read.rekeyBytes() } else { t.readBytesLeft = 1 << 30 } @@ -700,9 +704,9 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error { } } - kex, ok := kexAlgoMap[t.algorithms.kex] + kex, ok := kexAlgoMap[t.algorithms.KeyExchange] if !ok { - return fmt.Errorf("ssh: unexpected key exchange algorithm %v", t.algorithms.kex) + return fmt.Errorf("ssh: unexpected key exchange algorithm %v", t.algorithms.KeyExchange) } var result *kexResult @@ -809,12 +813,12 @@ func pickHostKey(hostKeys []Signer, algo string) AlgorithmSigner { } func (t *handshakeTransport) server(kex kexAlgorithm, magics *handshakeMagics) (*kexResult, error) { - hostKey := pickHostKey(t.hostKeys, t.algorithms.hostKey) + hostKey := pickHostKey(t.hostKeys, t.algorithms.HostKey) if hostKey == nil { return nil, errors.New("ssh: internal error: negotiated unsupported signature type") } - r, err := kex.Server(t.conn, t.config.Rand, magics, hostKey, t.algorithms.hostKey) + r, err := kex.Server(t.conn, t.config.Rand, magics, hostKey, t.algorithms.HostKey) return r, err } @@ -829,7 +833,7 @@ func (t *handshakeTransport) client(kex kexAlgorithm, magics *handshakeMagics) ( return nil, err } - if err := verifyHostKeySignature(hostKey, t.algorithms.hostKey, result); err != nil { + if err := verifyHostKeySignature(hostKey, t.algorithms.HostKey, result); err != nil { return nil, err } diff --git a/vendor/golang.org/x/crypto/ssh/kex.go b/vendor/golang.org/x/crypto/ssh/kex.go index 8a05f7990..cf388a92a 100644 --- a/vendor/golang.org/x/crypto/ssh/kex.go +++ b/vendor/golang.org/x/crypto/ssh/kex.go @@ -20,21 +20,18 @@ import ( ) const ( - kexAlgoDH1SHA1 = "diffie-hellman-group1-sha1" - kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1" - kexAlgoDH14SHA256 = "diffie-hellman-group14-sha256" - kexAlgoDH16SHA512 = "diffie-hellman-group16-sha512" - kexAlgoECDH256 = "ecdh-sha2-nistp256" - kexAlgoECDH384 = "ecdh-sha2-nistp384" - kexAlgoECDH521 = "ecdh-sha2-nistp521" - kexAlgoCurve25519SHA256LibSSH = "curve25519-sha256@libssh.org" - kexAlgoCurve25519SHA256 = "curve25519-sha256" - - // For the following kex only the client half contains a production - // ready implementation. The server half only consists of a minimal - // implementation to satisfy the automated tests. - kexAlgoDHGEXSHA1 = "diffie-hellman-group-exchange-sha1" - kexAlgoDHGEXSHA256 = "diffie-hellman-group-exchange-sha256" + // This is the group called diffie-hellman-group1-sha1 in RFC 4253 and + // Oakley Group 2 in RFC 2409. + oakleyGroup2 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF" + // This is the group called diffie-hellman-group14-sha1 in RFC 4253 and + // Oakley Group 14 in RFC 3526. + oakleyGroup14 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF" + // This is the group called diffie-hellman-group15-sha512 in RFC 8268 and + // Oakley Group 15 in RFC 3526. + oakleyGroup15 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF" + // This is the group called diffie-hellman-group16-sha512 in RFC 8268 and + // Oakley Group 16 in RFC 3526. + oakleyGroup16 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199FFFFFFFFFFFFFFFF" ) // kexResult captures the outcome of a key exchange. @@ -402,53 +399,46 @@ func ecHash(curve elliptic.Curve) crypto.Hash { var kexAlgoMap = map[string]kexAlgorithm{} func init() { - // This is the group called diffie-hellman-group1-sha1 in - // RFC 4253 and Oakley Group 2 in RFC 2409. - p, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF", 16) - kexAlgoMap[kexAlgoDH1SHA1] = &dhGroup{ + p, _ := new(big.Int).SetString(oakleyGroup2, 16) + kexAlgoMap[InsecureKeyExchangeDH1SHA1] = &dhGroup{ g: new(big.Int).SetInt64(2), p: p, pMinus1: new(big.Int).Sub(p, bigOne), hashFunc: crypto.SHA1, } - // This are the groups called diffie-hellman-group14-sha1 and - // diffie-hellman-group14-sha256 in RFC 4253 and RFC 8268, - // and Oakley Group 14 in RFC 3526. - p, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF", 16) + p, _ = new(big.Int).SetString(oakleyGroup14, 16) group14 := &dhGroup{ g: new(big.Int).SetInt64(2), p: p, pMinus1: new(big.Int).Sub(p, bigOne), } - kexAlgoMap[kexAlgoDH14SHA1] = &dhGroup{ + kexAlgoMap[InsecureKeyExchangeDH14SHA1] = &dhGroup{ g: group14.g, p: group14.p, pMinus1: group14.pMinus1, hashFunc: crypto.SHA1, } - kexAlgoMap[kexAlgoDH14SHA256] = &dhGroup{ + kexAlgoMap[KeyExchangeDH14SHA256] = &dhGroup{ g: group14.g, p: group14.p, pMinus1: group14.pMinus1, hashFunc: crypto.SHA256, } - // This is the group called diffie-hellman-group16-sha512 in RFC - // 8268 and Oakley Group 16 in RFC 3526. - p, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199FFFFFFFFFFFFFFFF", 16) + p, _ = new(big.Int).SetString(oakleyGroup16, 16) - kexAlgoMap[kexAlgoDH16SHA512] = &dhGroup{ + kexAlgoMap[KeyExchangeDH16SHA512] = &dhGroup{ g: new(big.Int).SetInt64(2), p: p, pMinus1: new(big.Int).Sub(p, bigOne), hashFunc: crypto.SHA512, } - kexAlgoMap[kexAlgoECDH521] = &ecdh{elliptic.P521()} - kexAlgoMap[kexAlgoECDH384] = &ecdh{elliptic.P384()} - kexAlgoMap[kexAlgoECDH256] = &ecdh{elliptic.P256()} - kexAlgoMap[kexAlgoCurve25519SHA256] = &curve25519sha256{} - kexAlgoMap[kexAlgoCurve25519SHA256LibSSH] = &curve25519sha256{} - kexAlgoMap[kexAlgoDHGEXSHA1] = &dhGEXSHA{hashFunc: crypto.SHA1} - kexAlgoMap[kexAlgoDHGEXSHA256] = &dhGEXSHA{hashFunc: crypto.SHA256} + kexAlgoMap[KeyExchangeECDHP521] = &ecdh{elliptic.P521()} + kexAlgoMap[KeyExchangeECDHP384] = &ecdh{elliptic.P384()} + kexAlgoMap[KeyExchangeECDHP256] = &ecdh{elliptic.P256()} + kexAlgoMap[KeyExchangeCurve25519] = &curve25519sha256{} + kexAlgoMap[keyExchangeCurve25519LibSSH] = &curve25519sha256{} + kexAlgoMap[InsecureKeyExchangeDHGEXSHA1] = &dhGEXSHA{hashFunc: crypto.SHA1} + kexAlgoMap[KeyExchangeDHGEXSHA256] = &dhGEXSHA{hashFunc: crypto.SHA256} } // curve25519sha256 implements the curve25519-sha256 (formerly known as @@ -601,9 +591,9 @@ const ( func (gex *dhGEXSHA) Client(c packetConn, randSource io.Reader, magics *handshakeMagics) (*kexResult, error) { // Send GexRequest kexDHGexRequest := kexDHGexRequestMsg{ - MinBits: dhGroupExchangeMinimumBits, - PreferedBits: dhGroupExchangePreferredBits, - MaxBits: dhGroupExchangeMaximumBits, + MinBits: dhGroupExchangeMinimumBits, + PreferredBits: dhGroupExchangePreferredBits, + MaxBits: dhGroupExchangeMaximumBits, } if err := c.writePacket(Marshal(&kexDHGexRequest)); err != nil { return nil, err @@ -690,9 +680,7 @@ func (gex *dhGEXSHA) Client(c packetConn, randSource io.Reader, magics *handshak } // Server half implementation of the Diffie Hellman Key Exchange with SHA1 and SHA256. -// -// This is a minimal implementation to satisfy the automated tests. -func (gex dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshakeMagics, priv AlgorithmSigner, algo string) (result *kexResult, err error) { +func (gex *dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshakeMagics, priv AlgorithmSigner, algo string) (result *kexResult, err error) { // Receive GexRequest packet, err := c.readPacket() if err != nil { @@ -702,13 +690,32 @@ func (gex dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshake if err = Unmarshal(packet, &kexDHGexRequest); err != nil { return } + // We check that the request received is valid and that the MaxBits + // requested are at least equal to our supported minimum. This is the same + // check done in OpenSSH: + // https://github.com/openssh/openssh-portable/blob/80a2f64b/kexgexs.c#L94 + // + // Furthermore, we also check that the required MinBits are less than or + // equal to 4096 because we can use up to Oakley Group 16. + if kexDHGexRequest.MaxBits < kexDHGexRequest.MinBits || kexDHGexRequest.PreferredBits < kexDHGexRequest.MinBits || + kexDHGexRequest.MaxBits < kexDHGexRequest.PreferredBits || kexDHGexRequest.MaxBits < dhGroupExchangeMinimumBits || + kexDHGexRequest.MinBits > 4096 { + return nil, fmt.Errorf("ssh: DH GEX request out of range, min: %d, max: %d, preferred: %d", kexDHGexRequest.MinBits, + kexDHGexRequest.MaxBits, kexDHGexRequest.PreferredBits) + } + + var p *big.Int + // We hardcode sending Oakley Group 14 (2048 bits), Oakley Group 15 (3072 + // bits) or Oakley Group 16 (4096 bits), based on the requested max size. + if kexDHGexRequest.MaxBits < 3072 { + p, _ = new(big.Int).SetString(oakleyGroup14, 16) + } else if kexDHGexRequest.MaxBits < 4096 { + p, _ = new(big.Int).SetString(oakleyGroup15, 16) + } else { + p, _ = new(big.Int).SetString(oakleyGroup16, 16) + } - // Send GexGroup - // This is the group called diffie-hellman-group14-sha1 in RFC - // 4253 and Oakley Group 14 in RFC 3526. - p, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF", 16) g := big.NewInt(2) - msg := &kexDHGexGroupMsg{ P: p, G: g, @@ -746,9 +753,9 @@ func (gex dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshake h := gex.hashFunc.New() magics.write(h) writeString(h, hostKeyBytes) - binary.Write(h, binary.BigEndian, uint32(dhGroupExchangeMinimumBits)) - binary.Write(h, binary.BigEndian, uint32(dhGroupExchangePreferredBits)) - binary.Write(h, binary.BigEndian, uint32(dhGroupExchangeMaximumBits)) + binary.Write(h, binary.BigEndian, kexDHGexRequest.MinBits) + binary.Write(h, binary.BigEndian, kexDHGexRequest.PreferredBits) + binary.Write(h, binary.BigEndian, kexDHGexRequest.MaxBits) writeInt(h, p) writeInt(h, g) writeInt(h, kexDHGexInit.X) diff --git a/vendor/golang.org/x/crypto/ssh/keys.go b/vendor/golang.org/x/crypto/ssh/keys.go index 98e6706d5..566e09d5a 100644 --- a/vendor/golang.org/x/crypto/ssh/keys.go +++ b/vendor/golang.org/x/crypto/ssh/keys.go @@ -36,14 +36,19 @@ import ( // ClientConfig.HostKeyAlgorithms, Signature.Format, or as AlgorithmSigner // arguments. const ( - KeyAlgoRSA = "ssh-rsa" - KeyAlgoDSA = "ssh-dss" - KeyAlgoECDSA256 = "ecdsa-sha2-nistp256" - KeyAlgoSKECDSA256 = "sk-ecdsa-sha2-nistp256@openssh.com" - KeyAlgoECDSA384 = "ecdsa-sha2-nistp384" - KeyAlgoECDSA521 = "ecdsa-sha2-nistp521" - KeyAlgoED25519 = "ssh-ed25519" - KeyAlgoSKED25519 = "sk-ssh-ed25519@openssh.com" + KeyAlgoRSA = "ssh-rsa" + // Deprecated: DSA is only supported at insecure key sizes, and was removed + // from major implementations. + KeyAlgoDSA = InsecureKeyAlgoDSA + // Deprecated: DSA is only supported at insecure key sizes, and was removed + // from major implementations. + InsecureKeyAlgoDSA = "ssh-dss" + KeyAlgoECDSA256 = "ecdsa-sha2-nistp256" + KeyAlgoSKECDSA256 = "sk-ecdsa-sha2-nistp256@openssh.com" + KeyAlgoECDSA384 = "ecdsa-sha2-nistp384" + KeyAlgoECDSA521 = "ecdsa-sha2-nistp521" + KeyAlgoED25519 = "ssh-ed25519" + KeyAlgoSKED25519 = "sk-ssh-ed25519@openssh.com" // KeyAlgoRSASHA256 and KeyAlgoRSASHA512 are only public key algorithms, not // public key formats, so they can't appear as a PublicKey.Type. The @@ -67,7 +72,7 @@ func parsePubKey(in []byte, algo string) (pubKey PublicKey, rest []byte, err err switch algo { case KeyAlgoRSA: return parseRSA(in) - case KeyAlgoDSA: + case InsecureKeyAlgoDSA: return parseDSA(in) case KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521: return parseECDSA(in) @@ -77,7 +82,7 @@ func parsePubKey(in []byte, algo string) (pubKey PublicKey, rest []byte, err err return parseED25519(in) case KeyAlgoSKED25519: return parseSKEd25519(in) - case CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoSKECDSA256v01, CertAlgoED25519v01, CertAlgoSKED25519v01: + case CertAlgoRSAv01, InsecureCertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoSKECDSA256v01, CertAlgoED25519v01, CertAlgoSKED25519v01: cert, err := parseCert(in, certKeyAlgoNames[algo]) if err != nil { return nil, nil, err diff --git a/vendor/golang.org/x/crypto/ssh/mac.go b/vendor/golang.org/x/crypto/ssh/mac.go index 06a1b2750..de2639d57 100644 --- a/vendor/golang.org/x/crypto/ssh/mac.go +++ b/vendor/golang.org/x/crypto/ssh/mac.go @@ -47,22 +47,22 @@ func (t truncatingMAC) Size() int { func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } var macModes = map[string]*macMode{ - "hmac-sha2-512-etm@openssh.com": {64, true, func(key []byte) hash.Hash { + HMACSHA512ETM: {64, true, func(key []byte) hash.Hash { return hmac.New(sha512.New, key) }}, - "hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash { + HMACSHA256ETM: {32, true, func(key []byte) hash.Hash { return hmac.New(sha256.New, key) }}, - "hmac-sha2-512": {64, false, func(key []byte) hash.Hash { + HMACSHA512: {64, false, func(key []byte) hash.Hash { return hmac.New(sha512.New, key) }}, - "hmac-sha2-256": {32, false, func(key []byte) hash.Hash { + HMACSHA256: {32, false, func(key []byte) hash.Hash { return hmac.New(sha256.New, key) }}, - "hmac-sha1": {20, false, func(key []byte) hash.Hash { + HMACSHA1: {20, false, func(key []byte) hash.Hash { return hmac.New(sha1.New, key) }}, - "hmac-sha1-96": {20, false, func(key []byte) hash.Hash { + InsecureHMACSHA196: {20, false, func(key []byte) hash.Hash { return truncatingMAC{12, hmac.New(sha1.New, key)} }}, } diff --git a/vendor/golang.org/x/crypto/ssh/messages.go b/vendor/golang.org/x/crypto/ssh/messages.go index 118427bc0..251b9d06a 100644 --- a/vendor/golang.org/x/crypto/ssh/messages.go +++ b/vendor/golang.org/x/crypto/ssh/messages.go @@ -122,9 +122,9 @@ type kexDHGexReplyMsg struct { const msgKexDHGexRequest = 34 type kexDHGexRequestMsg struct { - MinBits uint32 `sshtype:"34"` - PreferedBits uint32 - MaxBits uint32 + MinBits uint32 `sshtype:"34"` + PreferredBits uint32 + MaxBits uint32 } // See RFC 4253, section 10. diff --git a/vendor/golang.org/x/crypto/ssh/mlkem.go b/vendor/golang.org/x/crypto/ssh/mlkem.go index 40681dd69..657e1079d 100644 --- a/vendor/golang.org/x/crypto/ssh/mlkem.go +++ b/vendor/golang.org/x/crypto/ssh/mlkem.go @@ -19,19 +19,15 @@ import ( "golang.org/x/crypto/curve25519" ) -const ( - kexAlgoMLKEM768xCurve25519SHA256 = "mlkem768x25519-sha256" -) - func init() { // After Go 1.24rc1 mlkem swapped the order of return values of Encapsulate. // See #70950. if runtime.Version() == "go1.24rc1" { return } - supportedKexAlgos = slices.Insert(supportedKexAlgos, 0, kexAlgoMLKEM768xCurve25519SHA256) - preferredKexAlgos = slices.Insert(preferredKexAlgos, 0, kexAlgoMLKEM768xCurve25519SHA256) - kexAlgoMap[kexAlgoMLKEM768xCurve25519SHA256] = &mlkem768WithCurve25519sha256{} + supportedKexAlgos = slices.Insert(supportedKexAlgos, 0, KeyExchangeMLKEM768X25519) + defaultKexAlgos = slices.Insert(defaultKexAlgos, 0, KeyExchangeMLKEM768X25519) + kexAlgoMap[KeyExchangeMLKEM768X25519] = &mlkem768WithCurve25519sha256{} } // mlkem768WithCurve25519sha256 implements the hybrid ML-KEM768 with diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go index 1839ddc6a..98679ba5b 100644 --- a/vendor/golang.org/x/crypto/ssh/server.go +++ b/vendor/golang.org/x/crypto/ssh/server.go @@ -243,22 +243,15 @@ func NewServerConn(c net.Conn, config *ServerConfig) (*ServerConn, <-chan NewCha fullConf.MaxAuthTries = 6 } if len(fullConf.PublicKeyAuthAlgorithms) == 0 { - fullConf.PublicKeyAuthAlgorithms = supportedPubKeyAuthAlgos + fullConf.PublicKeyAuthAlgorithms = defaultPubKeyAuthAlgos } else { for _, algo := range fullConf.PublicKeyAuthAlgorithms { - if !contains(supportedPubKeyAuthAlgos, algo) { + if !contains(SupportedAlgorithms().PublicKeyAuths, algo) && !contains(InsecureAlgorithms().PublicKeyAuths, algo) { c.Close() return nil, nil, nil, fmt.Errorf("ssh: unsupported public key authentication algorithm %s", algo) } } } - // Check if the config contains any unsupported key exchanges - for _, kex := range fullConf.KeyExchanges { - if _, ok := serverForbiddenKexAlgos[kex]; ok { - c.Close() - return nil, nil, nil, fmt.Errorf("ssh: unsupported key exchange %s for server", kex) - } - } s := &connection{ sshConn: sshConn{conn: c}, @@ -315,6 +308,7 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error) // We just did the key change, so the session ID is established. s.sessionID = s.transport.getSessionID() + s.algorithms = s.transport.getAlgorithms() var packet []byte if packet, err = s.transport.readPacket(); err != nil { diff --git a/vendor/golang.org/x/crypto/ssh/transport.go b/vendor/golang.org/x/crypto/ssh/transport.go index 0424d2d37..663619845 100644 --- a/vendor/golang.org/x/crypto/ssh/transport.go +++ b/vendor/golang.org/x/crypto/ssh/transport.go @@ -16,13 +16,6 @@ import ( // wire. No message decoding is done, to minimize the impact on timing. const debugTransport = false -const ( - gcm128CipherID = "aes128-gcm@openssh.com" - gcm256CipherID = "aes256-gcm@openssh.com" - aes128cbcID = "aes128-cbc" - tripledescbcID = "3des-cbc" -) - // packetConn represents a transport that implements packet based // operations. type packetConn interface { @@ -92,14 +85,14 @@ func (t *transport) setInitialKEXDone() { // prepareKeyChange sets up key material for a keychange. The key changes in // both directions are triggered by reading and writing a msgNewKey packet // respectively. -func (t *transport) prepareKeyChange(algs *algorithms, kexResult *kexResult) error { - ciph, err := newPacketCipher(t.reader.dir, algs.r, kexResult) +func (t *transport) prepareKeyChange(algs *NegotiatedAlgorithms, kexResult *kexResult) error { + ciph, err := newPacketCipher(t.reader.dir, algs.Read, kexResult) if err != nil { return err } t.reader.pendingKeyChange <- ciph - ciph, err = newPacketCipher(t.writer.dir, algs.w, kexResult) + ciph, err = newPacketCipher(t.writer.dir, algs.Write, kexResult) if err != nil { return err } @@ -259,7 +252,7 @@ var ( // setupKeys sets the cipher and MAC keys from kex.K, kex.H and sessionId, as // described in RFC 4253, section 6.4. direction should either be serverKeys // (to setup server->client keys) or clientKeys (for client->server keys). -func newPacketCipher(d direction, algs directionAlgorithms, kex *kexResult) (packetCipher, error) { +func newPacketCipher(d direction, algs DirectionAlgorithms, kex *kexResult) (packetCipher, error) { cipherMode := cipherModes[algs.Cipher] iv := make([]byte, cipherMode.ivSize) diff --git a/vendor/golang.org/x/mod/semver/semver.go b/vendor/golang.org/x/mod/semver/semver.go index 9a2dfd33a..628f8fd68 100644 --- a/vendor/golang.org/x/mod/semver/semver.go +++ b/vendor/golang.org/x/mod/semver/semver.go @@ -22,7 +22,10 @@ // as shorthands for vMAJOR.0.0 and vMAJOR.MINOR.0. package semver -import "sort" +import ( + "slices" + "strings" +) // parsed returns the parsed form of a semantic version string. type parsed struct { @@ -154,19 +157,22 @@ func Max(v, w string) string { // ByVersion implements [sort.Interface] for sorting semantic version strings. type ByVersion []string -func (vs ByVersion) Len() int { return len(vs) } -func (vs ByVersion) Swap(i, j int) { vs[i], vs[j] = vs[j], vs[i] } -func (vs ByVersion) Less(i, j int) bool { - cmp := Compare(vs[i], vs[j]) - if cmp != 0 { - return cmp < 0 - } - return vs[i] < vs[j] -} +func (vs ByVersion) Len() int { return len(vs) } +func (vs ByVersion) Swap(i, j int) { vs[i], vs[j] = vs[j], vs[i] } +func (vs ByVersion) Less(i, j int) bool { return compareVersion(vs[i], vs[j]) < 0 } -// Sort sorts a list of semantic version strings using [ByVersion]. +// Sort sorts a list of semantic version strings using [Compare] and falls back +// to use [strings.Compare] if both versions are considered equal. func Sort(list []string) { - sort.Sort(ByVersion(list)) + slices.SortFunc(list, compareVersion) +} + +func compareVersion(a, b string) int { + cmp := Compare(a, b) + if cmp != 0 { + return cmp + } + return strings.Compare(a, b) } func parse(v string) (p parsed, ok bool) { diff --git a/vendor/golang.org/x/net/http2/frame.go b/vendor/golang.org/x/net/http2/frame.go index 97bd8b06f..db3264da8 100644 --- a/vendor/golang.org/x/net/http2/frame.go +++ b/vendor/golang.org/x/net/http2/frame.go @@ -39,7 +39,7 @@ const ( FrameContinuation FrameType = 0x9 ) -var frameName = map[FrameType]string{ +var frameNames = [...]string{ FrameData: "DATA", FrameHeaders: "HEADERS", FramePriority: "PRIORITY", @@ -53,10 +53,10 @@ var frameName = map[FrameType]string{ } func (t FrameType) String() string { - if s, ok := frameName[t]; ok { - return s + if int(t) < len(frameNames) { + return frameNames[t] } - return fmt.Sprintf("UNKNOWN_FRAME_TYPE_%d", uint8(t)) + return fmt.Sprintf("UNKNOWN_FRAME_TYPE_%d", t) } // Flags is a bitmask of HTTP/2 flags. @@ -124,7 +124,7 @@ var flagName = map[FrameType]map[Flags]string{ // might be 0). type frameParser func(fc *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) -var frameParsers = map[FrameType]frameParser{ +var frameParsers = [...]frameParser{ FrameData: parseDataFrame, FrameHeaders: parseHeadersFrame, FramePriority: parsePriorityFrame, @@ -138,8 +138,8 @@ var frameParsers = map[FrameType]frameParser{ } func typeFrameParser(t FrameType) frameParser { - if f := frameParsers[t]; f != nil { - return f + if int(t) < len(frameParsers) { + return frameParsers[t] } return parseUnknownFrame } @@ -509,7 +509,7 @@ func (fr *Framer) ReadFrame() (Frame, error) { } if fh.Length > fr.maxReadSize { if fh == invalidHTTP1LookingFrameHeader() { - return nil, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", err) + return nil, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", ErrFrameTooLarge) } return nil, ErrFrameTooLarge } diff --git a/vendor/golang.org/x/net/trace/events.go b/vendor/golang.org/x/net/trace/events.go index c646a6952..3aaffdd1f 100644 --- a/vendor/golang.org/x/net/trace/events.go +++ b/vendor/golang.org/x/net/trace/events.go @@ -508,7 +508,7 @@ const eventsHTML = ` {{$el.When}} {{$el.ElapsedTime}} - {{$el.Title}} + {{$el.Title}} {{if $.Expanded}} diff --git a/vendor/modules.txt b/vendor/modules.txt index 58a6954c1..fbb9719a1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -115,7 +115,7 @@ cuelang.org/go/pkg/uuid # dario.cat/mergo v1.0.1 ## explicit; go 1.13 dario.cat/mergo -# github.com/99designs/gqlgen v0.17.73 +# github.com/99designs/gqlgen v0.17.76 ## explicit; go 1.23.0 github.com/99designs/gqlgen/complexity github.com/99designs/gqlgen/graphql @@ -167,8 +167,8 @@ github.com/ProtonMail/go-crypto/openpgp/packet github.com/ProtonMail/go-crypto/openpgp/s2k github.com/ProtonMail/go-crypto/openpgp/x25519 github.com/ProtonMail/go-crypto/openpgp/x448 -# github.com/Yamashou/gqlgenc v0.32.1 -## explicit; go 1.24.2 +# github.com/Yamashou/gqlgenc v0.33.0 +## explicit; go 1.23.0 github.com/Yamashou/gqlgenc/clientv2 github.com/Yamashou/gqlgenc/graphqljson # github.com/agnivade/levenshtein v1.2.1 @@ -494,7 +494,7 @@ github.com/go-playground/universal-translator # github.com/go-playground/validator/v10 v10.26.0 ## explicit; go 1.20 github.com/go-playground/validator/v10 -# github.com/go-viper/mapstructure/v2 v2.2.1 +# github.com/go-viper/mapstructure/v2 v2.3.0 ## explicit; go 1.18 github.com/go-viper/mapstructure/v2 github.com/go-viper/mapstructure/v2/internal/errors @@ -662,7 +662,7 @@ github.com/muesli/termenv # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 ## explicit github.com/munnerz/goautoneg -# github.com/nhost/be v0.0.0-20250530082915-10b936caf233 +# github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb ## explicit; go 1.24.2 github.com/nhost/be/lib/graphql github.com/nhost/be/lib/graphql/context @@ -796,7 +796,7 @@ github.com/ulikunitz/xz github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma -# github.com/urfave/cli/v2 v2.27.6 +# github.com/urfave/cli/v2 v2.27.7 ## explicit; go 1.18 github.com/urfave/cli/v2 # github.com/valyala/bytebufferpool v1.0.0 @@ -805,7 +805,7 @@ github.com/valyala/bytebufferpool # github.com/valyala/fasttemplate v1.2.2 ## explicit; go 1.12 github.com/valyala/fasttemplate -# github.com/vektah/gqlparser/v2 v2.5.26 +# github.com/vektah/gqlparser/v2 v2.5.30 ## explicit; go 1.22 github.com/vektah/gqlparser/v2 github.com/vektah/gqlparser/v2/ast @@ -813,6 +813,7 @@ github.com/vektah/gqlparser/v2/gqlerror github.com/vektah/gqlparser/v2/lexer github.com/vektah/gqlparser/v2/parser github.com/vektah/gqlparser/v2/validator +github.com/vektah/gqlparser/v2/validator/core github.com/vektah/gqlparser/v2/validator/rules # github.com/wI2L/jsondiff v0.6.1 ## explicit; go 1.21 @@ -889,7 +890,7 @@ go.opentelemetry.io/otel/trace/noop # golang.org/x/arch v0.17.0 ## explicit; go 1.23.0 golang.org/x/arch/x86/x86asm -# golang.org/x/crypto v0.38.0 +# golang.org/x/crypto v0.39.0 ## explicit; go 1.23.0 golang.org/x/crypto/argon2 golang.org/x/crypto/blake2b @@ -909,10 +910,10 @@ golang.org/x/crypto/ssh golang.org/x/crypto/ssh/agent golang.org/x/crypto/ssh/internal/bcrypt_pbkdf golang.org/x/crypto/ssh/knownhosts -# golang.org/x/mod v0.24.0 +# golang.org/x/mod v0.25.0 ## explicit; go 1.23.0 golang.org/x/mod/semver -# golang.org/x/net v0.40.0 +# golang.org/x/net v0.41.0 ## explicit; go 1.23.0 golang.org/x/net/context golang.org/x/net/html @@ -939,7 +940,7 @@ golang.org/x/oauth2/google/internal/stsexchange golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt -# golang.org/x/sync v0.14.0 +# golang.org/x/sync v0.15.0 ## explicit; go 1.23.0 golang.org/x/sync/semaphore # golang.org/x/sys v0.33.0 @@ -953,7 +954,7 @@ golang.org/x/sys/windows/registry # golang.org/x/term v0.32.0 ## explicit; go 1.23.0 golang.org/x/term -# golang.org/x/text v0.25.0 +# golang.org/x/text v0.26.0 ## explicit; go 1.23.0 golang.org/x/text/cases golang.org/x/text/encoding From a10fafbe294460d4118eef00ca61404c5c14a893 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Tue, 29 Jul 2025 11:47:53 +0200 Subject: [PATCH 2/2] asdasd --- go.mod | 2 +- go.sum | 2 + gqlgenc.yaml | 1 - nhostclient/graphql/models_gen.go | 869 ++++++++++++++++++ .../nhost/be/services/mimir/schema/schema.cue | 2 +- vendor/modules.txt | 2 +- 6 files changed, 874 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index b20478b85..08c66a0b7 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 github.com/hashicorp/go-getter v1.7.8 - github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb + github.com/nhost/be v0.0.0-20250729094706-ada22fe1437e github.com/pelletier/go-toml/v2 v2.2.4 github.com/rs/cors/wrapper/gin v0.0.0-20240830163046-1084d89a1692 github.com/sirupsen/logrus v1.9.3 diff --git a/go.sum b/go.sum index 2114c608f..04dfc8008 100644 --- a/go.sum +++ b/go.sum @@ -1046,6 +1046,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb h1:ftbYufoc6iZA2jHOgjcsuraYbnvWzKFX4DoqGts9C4c= github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb/go.mod h1:Btk2JXy1ih/+VTlNItNNFfhOTZlKlrodBqXaJ+2K7Pg= +github.com/nhost/be v0.0.0-20250729094706-ada22fe1437e h1:F3Wi7p0pn+aIFLqCBlN0Rtvdgc/ym6F4fM7PDGYtUho= +github.com/nhost/be v0.0.0-20250729094706-ada22fe1437e/go.mod h1:Btk2JXy1ih/+VTlNItNNFfhOTZlKlrodBqXaJ+2K7Pg= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= diff --git a/gqlgenc.yaml b/gqlgenc.yaml index b8d89f2c6..0abb50b9a 100644 --- a/gqlgenc.yaml +++ b/gqlgenc.yaml @@ -33,4 +33,3 @@ query: - query/*.graphql generate: clientV2: true - omitEmptyTypes: true diff --git a/nhostclient/graphql/models_gen.go b/nhostclient/graphql/models_gen.go index 5091df530..267df0fbc 100644 --- a/nhostclient/graphql/models_gen.go +++ b/nhostclient/graphql/models_gen.go @@ -3,6 +3,7 @@ package graphql import ( + "bytes" "fmt" "io" "strconv" @@ -5550,6 +5551,20 @@ func (e CheckoutStatus) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *CheckoutStatus) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e CheckoutStatus) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type ServiceState string const ( @@ -5597,6 +5612,20 @@ func (e ServiceState) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *ServiceState) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e ServiceState) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "announcements_read" type AnnouncementsReadConstraint string @@ -5641,6 +5670,20 @@ func (e AnnouncementsReadConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AnnouncementsReadConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AnnouncementsReadConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "announcements_read" type AnnouncementsReadSelectColumn string @@ -5691,6 +5734,20 @@ func (e AnnouncementsReadSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AnnouncementsReadSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AnnouncementsReadSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // placeholder for update columns of table "announcements_read" (current role has no relevant permissions) type AnnouncementsReadUpdateColumn string @@ -5732,6 +5789,20 @@ func (e AnnouncementsReadUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AnnouncementsReadUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AnnouncementsReadUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "announcements" type AnnouncementsSelectColumn string @@ -5788,6 +5859,20 @@ func (e AnnouncementsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AnnouncementsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AnnouncementsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "app_state_history" type AppStateHistorySelectColumn string @@ -5841,6 +5926,20 @@ func (e AppStateHistorySelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AppStateHistorySelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AppStateHistorySelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "apps" type AppsConstraint string @@ -5888,6 +5987,20 @@ func (e AppsConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AppsConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AppsConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "apps" type AppsSelectColumn string @@ -5977,6 +6090,20 @@ func (e AppsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AppsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AppsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // update columns of table "apps" type AppsUpdateColumn string @@ -6036,6 +6163,20 @@ func (e AppsUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AppsUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AppsUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type AuthRefreshTokenTypesEnum string const ( @@ -6079,6 +6220,20 @@ func (e AuthRefreshTokenTypesEnum) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AuthRefreshTokenTypesEnum) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AuthRefreshTokenTypesEnum) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "auth.refresh_tokens" type AuthRefreshTokensSelectColumn string @@ -6135,6 +6290,20 @@ func (e AuthRefreshTokensSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AuthRefreshTokensSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AuthRefreshTokensSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "auth.user_providers" type AuthUserProvidersSelectColumn string @@ -6179,6 +6348,20 @@ func (e AuthUserProvidersSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AuthUserProvidersSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AuthUserProvidersSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "auth.user_security_keys" type AuthUserSecurityKeysSelectColumn string @@ -6226,6 +6409,20 @@ func (e AuthUserSecurityKeysSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *AuthUserSecurityKeysSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e AuthUserSecurityKeysSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "backups" type BackupsSelectColumn string @@ -6279,6 +6476,20 @@ func (e BackupsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *BackupsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e BackupsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "cli_tokens" type CliTokensSelectColumn string @@ -6326,6 +6537,20 @@ func (e CliTokensSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *CliTokensSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e CliTokensSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "continents" type ContinentsSelectColumn string @@ -6370,6 +6595,20 @@ func (e ContinentsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *ContinentsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e ContinentsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "countries" type CountriesSelectColumn string @@ -6420,6 +6659,20 @@ func (e CountriesSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *CountriesSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e CountriesSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // ordering argument of a cursor type CursorOrdering string @@ -6464,6 +6717,20 @@ func (e CursorOrdering) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *CursorOrdering) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e CursorOrdering) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "deployment_logs" type DeploymentLogsSelectColumn string @@ -6514,6 +6781,20 @@ func (e DeploymentLogsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *DeploymentLogsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e DeploymentLogsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "deployments" type DeploymentsConstraint string @@ -6555,6 +6836,20 @@ func (e DeploymentsConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *DeploymentsConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e DeploymentsConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "deployments" type DeploymentsSelectColumn string @@ -6647,6 +6942,20 @@ func (e DeploymentsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *DeploymentsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e DeploymentsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // placeholder for update columns of table "deployments" (current role has no relevant permissions) type DeploymentsUpdateColumn string @@ -6688,6 +6997,20 @@ func (e DeploymentsUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *DeploymentsUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e DeploymentsUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "feature_flags" type FeatureFlagsConstraint string @@ -6729,6 +7052,20 @@ func (e FeatureFlagsConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *FeatureFlagsConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e FeatureFlagsConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "feature_flags" type FeatureFlagsSelectColumn string @@ -6782,6 +7119,20 @@ func (e FeatureFlagsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *FeatureFlagsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e FeatureFlagsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // placeholder for update columns of table "feature_flags" (current role has no relevant permissions) type FeatureFlagsUpdateColumn string @@ -6823,6 +7174,20 @@ func (e FeatureFlagsUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *FeatureFlagsUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e FeatureFlagsUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "storage.files" type FilesSelectColumn string @@ -6894,6 +7259,20 @@ func (e FilesSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *FilesSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e FilesSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "github_app_installations" type GithubAppInstallationsConstraint string @@ -6938,6 +7317,20 @@ func (e GithubAppInstallationsConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *GithubAppInstallationsConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e GithubAppInstallationsConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "github_app_installations" type GithubAppInstallationsSelectColumn string @@ -6994,6 +7387,20 @@ func (e GithubAppInstallationsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *GithubAppInstallationsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e GithubAppInstallationsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // placeholder for update columns of table "github_app_installations" (current role has no relevant permissions) type GithubAppInstallationsUpdateColumn string @@ -7035,6 +7442,20 @@ func (e GithubAppInstallationsUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *GithubAppInstallationsUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e GithubAppInstallationsUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "github_repositories" type GithubRepositoriesSelectColumn string @@ -7091,6 +7512,20 @@ func (e GithubRepositoriesSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *GithubRepositoriesSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e GithubRepositoriesSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // column ordering options type OrderBy string @@ -7147,6 +7582,20 @@ func (e OrderBy) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrderBy) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrderBy) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type OrganizationCostsThresholdsEnum string const ( @@ -7196,6 +7645,20 @@ func (e OrganizationCostsThresholdsEnum) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationCostsThresholdsEnum) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationCostsThresholdsEnum) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "organization_member_invites" type OrganizationMemberInvitesConstraint string @@ -7240,6 +7703,20 @@ func (e OrganizationMemberInvitesConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationMemberInvitesConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationMemberInvitesConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "organization_member_invites" type OrganizationMemberInvitesSelectColumn string @@ -7296,6 +7773,20 @@ func (e OrganizationMemberInvitesSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationMemberInvitesSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationMemberInvitesSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // update columns of table "organization_member_invites" type OrganizationMemberInvitesUpdateColumn string @@ -7337,6 +7828,20 @@ func (e OrganizationMemberInvitesUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationMemberInvitesUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationMemberInvitesUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type OrganizationMembersRoleEnum string const ( @@ -7380,6 +7885,20 @@ func (e OrganizationMembersRoleEnum) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationMembersRoleEnum) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationMembersRoleEnum) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "organization_members" type OrganizationMembersSelectColumn string @@ -7436,6 +7955,20 @@ func (e OrganizationMembersSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationMembersSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationMembersSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "organization_new_request" type OrganizationNewRequestSelectColumn string @@ -7492,6 +8025,20 @@ func (e OrganizationNewRequestSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationNewRequestSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationNewRequestSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type OrganizationStatusEnum string const ( @@ -7544,6 +8091,20 @@ func (e OrganizationStatusEnum) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationStatusEnum) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationStatusEnum) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "organizations" type OrganizationsSelectColumn string @@ -7609,6 +8170,20 @@ func (e OrganizationsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *OrganizationsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e OrganizationsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "payment_methods" type PaymentMethodsConstraint string @@ -7650,6 +8225,20 @@ func (e PaymentMethodsConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *PaymentMethodsConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e PaymentMethodsConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "payment_methods" type PaymentMethodsSelectColumn string @@ -7718,6 +8307,20 @@ func (e PaymentMethodsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *PaymentMethodsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e PaymentMethodsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // update columns of table "payment_methods" type PaymentMethodsUpdateColumn string @@ -7759,6 +8362,20 @@ func (e PaymentMethodsUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *PaymentMethodsUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e PaymentMethodsUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "plans" type PlansSelectColumn string @@ -7842,6 +8459,20 @@ func (e PlansSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *PlansSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e PlansSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type RegionTypeEnum string const ( @@ -7885,6 +8516,20 @@ func (e RegionTypeEnum) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *RegionTypeEnum) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e RegionTypeEnum) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "regions_allowed_organization" type RegionsAllowedOrganizationSelectColumn string @@ -7941,6 +8586,20 @@ func (e RegionsAllowedOrganizationSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *RegionsAllowedOrganizationSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e RegionsAllowedOrganizationSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "regions_allowed_workspace" type RegionsAllowedWorkspaceSelectColumn string @@ -7997,6 +8656,20 @@ func (e RegionsAllowedWorkspaceSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *RegionsAllowedWorkspaceSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e RegionsAllowedWorkspaceSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "regions" type RegionsSelectColumn string @@ -8065,6 +8738,20 @@ func (e RegionsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *RegionsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e RegionsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "run_service" type RunServiceSelectColumn string @@ -8118,6 +8805,20 @@ func (e RunServiceSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *RunServiceSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e RunServiceSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + type SoftwareTypeEnum string const ( @@ -8170,6 +8871,20 @@ func (e SoftwareTypeEnum) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *SoftwareTypeEnum) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e SoftwareTypeEnum) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "software_versions" type SoftwareVersionsSelectColumn string @@ -8217,6 +8932,20 @@ func (e SoftwareVersionsSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *SoftwareVersionsSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e SoftwareVersionsSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "auth.users" type UsersSelectColumn string @@ -8270,6 +8999,20 @@ func (e UsersSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *UsersSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e UsersSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "workspace_member_invites" type WorkspaceMemberInvitesConstraint string @@ -8314,6 +9057,20 @@ func (e WorkspaceMemberInvitesConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspaceMemberInvitesConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspaceMemberInvitesConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "workspace_member_invites" type WorkspaceMemberInvitesSelectColumn string @@ -8373,6 +9130,20 @@ func (e WorkspaceMemberInvitesSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspaceMemberInvitesSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspaceMemberInvitesSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // update columns of table "workspace_member_invites" type WorkspaceMemberInvitesUpdateColumn string @@ -8414,6 +9185,20 @@ func (e WorkspaceMemberInvitesUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspaceMemberInvitesUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspaceMemberInvitesUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "workspace_members" type WorkspaceMembersConstraint string @@ -8458,6 +9243,20 @@ func (e WorkspaceMembersConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspaceMembersConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspaceMembersConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "workspace_members" type WorkspaceMembersSelectColumn string @@ -8514,6 +9313,20 @@ func (e WorkspaceMembersSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspaceMembersSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspaceMembersSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // update columns of table "workspace_members" type WorkspaceMembersUpdateColumn string @@ -8555,6 +9368,20 @@ func (e WorkspaceMembersUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspaceMembersUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspaceMembersUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // unique or primary key constraints on table "workspaces" type WorkspacesConstraint string @@ -8599,6 +9426,20 @@ func (e WorkspacesConstraint) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspacesConstraint) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspacesConstraint) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // select columns of table "workspaces" type WorkspacesSelectColumn string @@ -8685,6 +9526,20 @@ func (e WorkspacesSelectColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } +func (e *WorkspacesSelectColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspacesSelectColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} + // update columns of table "workspaces" type WorkspacesUpdateColumn string @@ -8758,3 +9613,17 @@ func (e *WorkspacesUpdateColumn) UnmarshalGQL(v any) error { func (e WorkspacesUpdateColumn) MarshalGQL(w io.Writer) { fmt.Fprint(w, strconv.Quote(e.String())) } + +func (e *WorkspacesUpdateColumn) UnmarshalJSON(b []byte) error { + s, err := strconv.Unquote(string(b)) + if err != nil { + return err + } + return e.UnmarshalGQL(s) +} + +func (e WorkspacesUpdateColumn) MarshalJSON() ([]byte, error) { + var buf bytes.Buffer + e.MarshalGQL(&buf) + return buf.Bytes(), nil +} 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 a66dcb5a1..23303e007 100644 --- a/vendor/github.com/nhost/be/services/mimir/schema/schema.cue +++ b/vendor/github.com/nhost/be/services/mimir/schema/schema.cue @@ -254,7 +254,7 @@ import ( #Postgres: { // Version of postgres, you can see available versions in the URL below: // https://hub.docker.com/r/nhost/postgres/tags - version: string | *"14.17-20250728-1" + version: string | *"14.18-20250728-1" // Resources for the service resources: { diff --git a/vendor/modules.txt b/vendor/modules.txt index fbb9719a1..4dbf96243 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -662,7 +662,7 @@ github.com/muesli/termenv # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 ## explicit github.com/munnerz/goautoneg -# github.com/nhost/be v0.0.0-20250729074615-4c9a31b695cb +# github.com/nhost/be v0.0.0-20250729094706-ada22fe1437e ## explicit; go 1.24.2 github.com/nhost/be/lib/graphql github.com/nhost/be/lib/graphql/context