From e5c5370ad0680ee76d93e2a0f4e2ddbb7af12763 Mon Sep 17 00:00:00 2001 From: Ayrton Date: Tue, 20 Oct 2026 13:38:31 +0200 Subject: [PATCH] Show internal parameters in CLI output --- internal/cmd/admin/admin.go | 2 ++ internal/cmd/admin/admin_test.go | 2 +- internal/cmd/branch/parameters.go | 2 ++ internal/cmd/branch/parameters_test.go | 12 ++++++++---- internal/cmd/configprofile/config_profile.go | 2 ++ internal/cmd/configprofile/config_profile_test.go | 13 +++++++------ internal/cmd/router/router.go | 2 ++ internal/cmd/sidecar/sidecar.go | 2 ++ internal/cmd/sidecar/sidecar_test.go | 2 +- .../neki_shard_configuration_profiles.go | 1 + internal/planetscale/postgres_bouncers.go | 1 + internal/planetscale/postgres_branches.go | 1 + 12 files changed, 30 insertions(+), 12 deletions(-) diff --git a/internal/cmd/admin/admin.go b/internal/cmd/admin/admin.go index 8c2476f5..f4e61aea 100644 --- a/internal/cmd/admin/admin.go +++ b/internal/cmd/admin/admin.go @@ -100,6 +100,7 @@ type parameterDisplay struct { Default string `header:"default" json:"default_value"` Type string `header:"type" json:"parameter_type"` Restart bool `header:"restart" json:"restart"` + Internal bool `header:"internal" json:"internal"` RequiresUpdate bool `header:"requires update" json:"requires_update"` orig *ps.NekiParameter @@ -123,6 +124,7 @@ func toParameters(parameters []*ps.NekiParameter) []*parameterDisplay { Default: formatValue(parameter.DefaultValue), Type: parameter.ParameterType, Restart: parameter.Restart, + Internal: parameter.Internal, RequiresUpdate: parameter.RequiresUpdate != nil, orig: parameter, }) diff --git a/internal/cmd/admin/admin_test.go b/internal/cmd/admin/admin_test.go index bfd370d7..cfd31c44 100644 --- a/internal/cmd/admin/admin_test.go +++ b/internal/cmd/admin/admin_test.go @@ -172,7 +172,7 @@ func TestAdminParametersCmd(t *testing.T) { cmd.SetArgs([]string{"app", "main"}) c.Assert(cmd.Execute(), qt.IsNil) c.Assert(out.String(), qt.JSONEquals, []map[string]interface{}{{ - "name": "recovery-poll-interval", "display_name": "", "namespace": "admin", "advanced": false, + "name": "recovery-poll-interval", "display_name": "", "namespace": "admin", "advanced": false, "internal": false, "category": nil, "description": "", "parameter_type": "", "default_value": nil, "value": "20s", "required": false, "created_at": "0001-01-01T00:00:00Z", "updated_at": nil, "restart": false, "url": "", "requires_update": nil, }}) diff --git a/internal/cmd/branch/parameters.go b/internal/cmd/branch/parameters.go index 2c049bbc..84d4c11a 100644 --- a/internal/cmd/branch/parameters.go +++ b/internal/cmd/branch/parameters.go @@ -111,6 +111,7 @@ type postgresParameter struct { Default string `header:"default" json:"default_value"` Type string `header:"type" json:"parameter_type"` Restart bool `header:"restart" json:"restart"` + Internal bool `header:"internal" json:"internal"` RequiresUpdate bool `header:"requires update" json:"requires_update"` orig *ps.PostgresParameter @@ -126,6 +127,7 @@ func toPostgresParameters(parameters []*ps.PostgresParameter) []*postgresParamet Default: formatParameterValue(param.DefaultValue), Type: param.ParameterType, Restart: param.Restart, + Internal: param.Internal, RequiresUpdate: param.RequiresUpdate != nil, orig: param, }) diff --git a/internal/cmd/branch/parameters_test.go b/internal/cmd/branch/parameters_test.go index 21266a5d..795047f3 100644 --- a/internal/cmd/branch/parameters_test.go +++ b/internal/cmd/branch/parameters_test.go @@ -39,6 +39,7 @@ func TestBranch_ParametersCmd(t *testing.T) { return []*ps.PostgresParameter{ {Namespace: "pgconf", Name: "max_connections", Value: "200", DefaultValue: "100", ParameterType: "integer", Restart: true, RequiresUpdate: &requiresUpdate}, {Namespace: "pgbouncer", Name: "default_pool_size", Value: "20", DefaultValue: "20", ParameterType: "integer"}, + {Namespace: "pgconf", Name: "archive_timeout", Internal: true}, }, nil }, } @@ -65,6 +66,8 @@ func TestBranch_ParametersCmd(t *testing.T) { c.Assert(json.Unmarshal(buf.Bytes(), ¶meters), qt.IsNil) c.Assert(parameters[0]["requires_update"], qt.Equals, "cluster") c.Assert(parameters[1]["requires_update"], qt.IsNil) + c.Assert(parameters[0]["internal"], qt.Equals, false) + c.Assert(parameters[2]["internal"], qt.Equals, true) c.Assert(buf.String(), qt.Contains, `"requires_update": null`) } @@ -139,11 +142,11 @@ func TestBranch_ParametersCmd_NamespaceFilter(t *testing.T) { c.Assert(buf.String(), qt.Not(qt.Contains), "max_connections") } -func TestBranch_ParametersRequiresUpdateTable(t *testing.T) { +func TestBranch_ParametersTable(t *testing.T) { c := qt.New(t) var parameters []*ps.PostgresParameter c.Assert(json.Unmarshal([]byte(`[ - {"namespace":"pgconf","name":"locked","requires_update":"cluster"}, + {"namespace":"pgconf","name":"locked","internal":true,"requires_update":"cluster"}, {"namespace":"pgconf","name":"editable","requires_update":null} ]`), ¶meters), qt.IsNil) @@ -156,6 +159,7 @@ func TestBranch_ParametersRequiresUpdateTable(t *testing.T) { lines := strings.Split(strings.TrimSpace(out.String()), "\n") c.Assert(len(lines), qt.Equals, 4) c.Assert(lines[0], qt.Contains, "REQUIRES UPDATE") - c.Assert(strings.Fields(lines[2]), qt.DeepEquals, []string{"pgconf", "locked", "No", "Yes"}) - c.Assert(strings.Fields(lines[3]), qt.DeepEquals, []string{"pgconf", "editable", "No", "No"}) + c.Assert(lines[0], qt.Contains, "INTERNAL") + c.Assert(strings.Fields(lines[2]), qt.DeepEquals, []string{"pgconf", "locked", "No", "Yes", "Yes"}) + c.Assert(strings.Fields(lines[3]), qt.DeepEquals, []string{"pgconf", "editable", "No", "No", "No"}) } diff --git a/internal/cmd/configprofile/config_profile.go b/internal/cmd/configprofile/config_profile.go index 2c887719..32c4708d 100644 --- a/internal/cmd/configprofile/config_profile.go +++ b/internal/cmd/configprofile/config_profile.go @@ -79,6 +79,7 @@ type parameterDisplay struct { Default string `header:"default" json:"default_value"` Type string `header:"type" json:"parameter_type"` Restart bool `header:"restart" json:"restart"` + Internal bool `header:"internal" json:"internal"` Required bool `header:"required" json:"required"` RequiresUpdate bool `header:"requires update" json:"requires_update"` orig *ps.NekiParameter @@ -108,6 +109,7 @@ func toParameters(parameters []*ps.NekiParameter) []*parameterDisplay { Default: formatValue(p.DefaultValue), Type: p.ParameterType, Restart: p.Restart, + Internal: p.Internal, Required: p.Required, RequiresUpdate: p.RequiresUpdate != nil, orig: p, diff --git a/internal/cmd/configprofile/config_profile_test.go b/internal/cmd/configprofile/config_profile_test.go index 9b963a43..20f17e65 100644 --- a/internal/cmd/configprofile/config_profile_test.go +++ b/internal/cmd/configprofile/config_profile_test.go @@ -382,17 +382,17 @@ func TestConfigProfileParametersCmd(t *testing.T) { cmd.SetArgs([]string{"app", "main", "metal", "--namespace", "pgconf", "--extension"}) c.Assert(cmd.Execute(), qt.IsNil) c.Assert(out.String(), qt.JSONEquals, []map[string]interface{}{{ - "name": "work_mem", "display_name": "", "namespace": "pgconf", "advanced": false, + "name": "work_mem", "display_name": "", "namespace": "pgconf", "advanced": false, "internal": false, "category": nil, "description": "", "parameter_type": "", "default_value": nil, "value": "64MB", "required": false, "created_at": "0001-01-01T00:00:00Z", "updated_at": nil, "restart": false, "url": "", "requires_update": "configuration_profile", }}) } -func TestConfigProfileParametersRequiresUpdateTable(t *testing.T) { +func TestConfigProfileParametersTable(t *testing.T) { c := qt.New(t) var parameters []*ps.NekiParameter c.Assert(json.Unmarshal([]byte(`[ - {"namespace":"pgconf","name":"profile_locked","requires_update":"configuration_profile"}, + {"namespace":"pgconf","name":"profile_locked","internal":true,"requires_update":"configuration_profile"}, {"namespace":"pgconf","name":"cluster_locked","requires_update":"cluster"}, {"namespace":"pgconf","name":"editable","requires_update":null} ]`), ¶meters), qt.IsNil) @@ -406,9 +406,10 @@ func TestConfigProfileParametersRequiresUpdateTable(t *testing.T) { lines := strings.Split(strings.TrimSpace(out.String()), "\n") c.Assert(len(lines), qt.Equals, 5) c.Assert(lines[0], qt.Contains, "REQUIRES UPDATE") - c.Assert(strings.Fields(lines[2]), qt.DeepEquals, []string{"pgconf", "profile_locked", "No", "No", "Yes"}) - c.Assert(strings.Fields(lines[3]), qt.DeepEquals, []string{"pgconf", "cluster_locked", "No", "No", "Yes"}) - c.Assert(strings.Fields(lines[4]), qt.DeepEquals, []string{"pgconf", "editable", "No", "No", "No"}) + c.Assert(lines[0], qt.Contains, "INTERNAL") + c.Assert(strings.Fields(lines[2]), qt.DeepEquals, []string{"pgconf", "profile_locked", "No", "Yes", "No", "Yes"}) + c.Assert(strings.Fields(lines[3]), qt.DeepEquals, []string{"pgconf", "cluster_locked", "No", "No", "No", "Yes"}) + c.Assert(strings.Fields(lines[4]), qt.DeepEquals, []string{"pgconf", "editable", "No", "No", "No", "No"}) } func TestConfigProfileChangesCancelCmd(t *testing.T) { diff --git a/internal/cmd/router/router.go b/internal/cmd/router/router.go index 553bda40..8e745d8d 100644 --- a/internal/cmd/router/router.go +++ b/internal/cmd/router/router.go @@ -109,6 +109,7 @@ type parameterDisplay struct { Default string `header:"default" json:"default_value"` Type string `header:"type" json:"parameter_type"` Restart bool `header:"restart" json:"restart"` + Internal bool `header:"internal" json:"internal"` orig *ps.NekiParameter } @@ -131,6 +132,7 @@ func toParameters(parameters []*ps.NekiParameter) []*parameterDisplay { Default: formatValue(parameter.DefaultValue), Type: parameter.ParameterType, Restart: parameter.Restart, + Internal: parameter.Internal, orig: parameter, }) } diff --git a/internal/cmd/sidecar/sidecar.go b/internal/cmd/sidecar/sidecar.go index e3d2a25a..ecdd2b4c 100644 --- a/internal/cmd/sidecar/sidecar.go +++ b/internal/cmd/sidecar/sidecar.go @@ -89,6 +89,7 @@ type parameterDisplay struct { Default string `header:"default" json:"default_value"` Type string `header:"type" json:"parameter_type"` Restart bool `header:"restart" json:"restart"` + Internal bool `header:"internal" json:"internal"` RequiresUpdate bool `header:"requires update" json:"requires_update"` orig *ps.NekiParameter @@ -112,6 +113,7 @@ func toParameters(parameters []*ps.NekiParameter) []*parameterDisplay { Default: formatValue(parameter.DefaultValue), Type: parameter.ParameterType, Restart: parameter.Restart, + Internal: parameter.Internal, RequiresUpdate: parameter.RequiresUpdate != nil, orig: parameter, }) diff --git a/internal/cmd/sidecar/sidecar_test.go b/internal/cmd/sidecar/sidecar_test.go index e43db34c..42d4eed9 100644 --- a/internal/cmd/sidecar/sidecar_test.go +++ b/internal/cmd/sidecar/sidecar_test.go @@ -187,7 +187,7 @@ func TestSidecarParametersCmd(t *testing.T) { cmd.SetArgs([]string{"app", "main", "metal"}) c.Assert(cmd.Execute(), qt.IsNil) c.Assert(out.String(), qt.JSONEquals, []map[string]interface{}{{ - "name": "default_pool_size", "display_name": "", "namespace": "pgbouncer", "advanced": false, + "name": "default_pool_size", "display_name": "", "namespace": "pgbouncer", "advanced": false, "internal": false, "category": nil, "description": "", "parameter_type": "", "default_value": nil, "value": "20", "required": false, "created_at": "0001-01-01T00:00:00Z", "updated_at": nil, "restart": false, "url": "", "requires_update": nil, }}) diff --git a/internal/planetscale/neki_shard_configuration_profiles.go b/internal/planetscale/neki_shard_configuration_profiles.go index 54b82841..d42e26f7 100644 --- a/internal/planetscale/neki_shard_configuration_profiles.go +++ b/internal/planetscale/neki_shard_configuration_profiles.go @@ -112,6 +112,7 @@ type NekiParameter struct { CreatedAt time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Restart bool `json:"restart"` + Internal bool `json:"internal"` RequiresUpdate *string `json:"requires_update"` // Min, Max, and Step are numbers for plain numeric parameters but strings // for byte- and time-typed ones (for example, "128kB" or "10min"). diff --git a/internal/planetscale/postgres_bouncers.go b/internal/planetscale/postgres_bouncers.go index e953b4d7..2338ff4a 100644 --- a/internal/planetscale/postgres_bouncers.go +++ b/internal/planetscale/postgres_bouncers.go @@ -39,6 +39,7 @@ type PostgresBouncerParameter struct { Value string `json:"value"` Required bool `json:"required"` Restart bool `json:"restart"` + Internal bool `json:"internal"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } diff --git a/internal/planetscale/postgres_branches.go b/internal/planetscale/postgres_branches.go index 91bc9373..8a5abfc7 100644 --- a/internal/planetscale/postgres_branches.go +++ b/internal/planetscale/postgres_branches.go @@ -217,6 +217,7 @@ type PostgresParameter struct { Value any `json:"value"` Required bool `json:"required"` Restart bool `json:"restart"` + Internal bool `json:"internal"` RequiresUpdate *string `json:"requires_update"` // Min, Max, and Step are numbers for plain numeric parameters but strings