Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/cmd/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
})
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/admin/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}})
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/branch/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
})
Expand Down
12 changes: 8 additions & 4 deletions internal/cmd/branch/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}
Expand All @@ -65,6 +66,8 @@ func TestBranch_ParametersCmd(t *testing.T) {
c.Assert(json.Unmarshal(buf.Bytes(), &parameters), 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`)
}

Expand Down Expand Up @@ -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}
]`), &parameters), qt.IsNil)

Expand All @@ -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"})
}
2 changes: 2 additions & 0 deletions internal/cmd/configprofile/config_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 7 additions & 6 deletions internal/cmd/configprofile/config_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]`), &parameters), qt.IsNil)
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
})
}
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/sidecar/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
})
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/sidecar/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down
1 change: 1 addition & 0 deletions internal/planetscale/postgres_bouncers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
1 change: 1 addition & 0 deletions internal/planetscale/postgres_branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading