Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pg config #254

Merged
merged 2 commits into from
Oct 29, 2024
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
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnkeycloak/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
)

// AddServiceBillingLabel adds billingLabel to all the objects of a services that must be billed
func AddServiceBillingLabel(ctx context.Context, comp *v1.VSHNKeycloak, svc *runtime.ServiceRuntime) *xfnproto.Result {
// AddBilling enables billing for this service
func AddBilling(ctx context.Context, comp *v1.VSHNKeycloak, svc *runtime.ServiceRuntime) *xfnproto.Result {
err := svc.GetObservedComposite(comp)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("can't get composite: %w", err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/comp-functions/functions/vshnkeycloak/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
},
{
Name: "billing",
Execute: AddServiceBillingLabel,
Execute: AddBilling,
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnmariadb/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
)

// AddServiceBillingLabel adds billingLabel to all the objects of a services that must be billed
func AddServiceBillingLabel(ctx context.Context, comp *v1.VSHNMariaDB, svc *runtime.ServiceRuntime) *xfnproto.Result {
// AddBilling enables billing for this service
func AddBilling(ctx context.Context, comp *v1.VSHNMariaDB, svc *runtime.ServiceRuntime) *xfnproto.Result {
err := svc.GetObservedComposite(comp)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("can't get composite: %w", err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/comp-functions/functions/vshnmariadb/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func init() {
},
{
Name: "billing",
Execute: AddServiceBillingLabel,
Execute: AddBilling,
},
{
Name: "user-management",
Expand Down
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnminio/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
)

// AddServiceBillingLabel adds billingLabel to all the objects of a services that must be billed
func AddServiceBillingLabel(ctx context.Context, comp *v1.VSHNMinio, svc *runtime.ServiceRuntime) *xfnproto.Result {
// AddBilling enables billing for this service
func AddBilling(ctx context.Context, comp *v1.VSHNMinio, svc *runtime.ServiceRuntime) *xfnproto.Result {
err := svc.GetObservedComposite(comp)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("can't get composite: %w", err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/comp-functions/functions/vshnminio/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func init() {
},
{
Name: "billing",
Execute: AddServiceBillingLabel,
Execute: AddBilling,
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnnextcloud/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
)

// AddServiceBillingLabel adds billingLabel to all the objects of a services that must be billed
func AddServiceBillingLabel(ctx context.Context, comp *v1.VSHNNextcloud, svc *runtime.ServiceRuntime) *xfnproto.Result {
// AddBilling enables billing for this service
func AddBilling(ctx context.Context, comp *v1.VSHNNextcloud, svc *runtime.ServiceRuntime) *xfnproto.Result {

err := svc.GetObservedComposite(comp)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/comp-functions/functions/vshnnextcloud/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func init() {
},
{
Name: "billing",
Execute: AddServiceBillingLabel,
Execute: AddBilling,
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnpostgres/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
)

// AddServiceBillingLabel adds billingLabel to all the objects of a services that must be billed
func AddServiceBillingLabel(ctx context.Context, comp *v1.VSHNPostgreSQL, svc *runtime.ServiceRuntime) *xfnproto.Result {
// AddBilling enables billing for this service
func AddBilling(ctx context.Context, comp *v1.VSHNPostgreSQL, svc *runtime.ServiceRuntime) *xfnproto.Result {
err := svc.GetObservedComposite(comp)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("can't get composite: %w", err))
Expand Down
8 changes: 4 additions & 4 deletions pkg/comp-functions/functions/vshnpostgres/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func AddExtensions(ctx context.Context, comp *vshnv1.VSHNPostgreSQL, svc *runtim
return runtime.NewFatalResult(fmt.Errorf("cannot add timescaldb to config: %w", err))
}
} else {
err := disableTimescaleDB(ctx, svc)
err := disableTimescaleDB(ctx, svc, comp.GetName())
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("cannot ensure timescaldb absent from config: %w", err))
}
Expand Down Expand Up @@ -105,10 +105,10 @@ func enableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime, name st
config.Spec.PostgresqlConf[sharedLibraries] = fmt.Sprintf("%s,%s", toAppend, timescaleExtName)
}

return svc.SetDesiredKubeObjectWithName(config, name+"-"+configResourceName, configResourceName)
return svc.SetDesiredKubeObject(config, name+"-"+configResourceName)
}

func disableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime) error {
func disableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime, name string) error {

config := &stackgresv1.SGPostgresConfig{}

Expand All @@ -135,5 +135,5 @@ func disableTimescaleDB(ctx context.Context, svc *runtime.ServiceRuntime) error

config.Spec.PostgresqlConf[sharedLibraries] = strings.Join(finalElements, ", ")

return svc.SetDesiredKubeObject(config, configResourceName)
return svc.SetDesiredKubeObject(config, name+"-"+configResourceName)
}
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnpostgres/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Test_enableTimescaleDB(t *testing.T) {

config := &stackgresv1.SGPostgresConfig{}

assert.NoError(t, svc.GetDesiredKubeObject(config, configResourceName))
assert.NoError(t, svc.GetDesiredKubeObject(config, comp.GetName()+"-"+configResourceName))

assert.Contains(t, config.Spec.PostgresqlConf[sharedLibraries], timescaleExtName)

Expand Down Expand Up @@ -81,7 +81,7 @@ func Test_disableTimescaleDB(t *testing.T) {
svc := commontest.LoadRuntimeFromFile(t, tt.iofFile)

t.Run(tt.name, func(t *testing.T) {
if err := disableTimescaleDB(ctx, svc); (err != nil) != tt.wantErr {
if err := disableTimescaleDB(ctx, svc, configResourceName); (err != nil) != tt.wantErr {
t.Errorf("disableTimescaleDB() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func createSgPostgresConfig(comp *vshnv1.VSHNPostgreSQL, svc *runtime.ServiceRun
},
}

err := svc.SetDesiredKubeObjectWithName(sgPostgresConfig, comp.GetName()+"-pgconf", "pg-conf")
err := svc.SetDesiredKubeObject(sgPostgresConfig, comp.GetName()+"-"+configResourceName)
if err != nil {
err = fmt.Errorf("cannot create sgInstanceProfile: %w", err)
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestPostgreSqlDeploy(t *testing.T) {
assert.Nil(t, sgInstanceProfile.Spec.HugePages)

sgPostgresConfig := &sgv1.SGPostgresConfig{}
assert.NoError(t, svc.GetDesiredKubeObject(sgPostgresConfig, "pg-conf"))
assert.NoError(t, svc.GetDesiredKubeObject(sgPostgresConfig, comp.GetName()+"-"+configResourceName))
assert.Equal(t, comp.Spec.Parameters.Service.MajorVersion, sgPostgresConfig.Spec.PostgresVersion)
assert.Equal(t, map[string]string{}, sgPostgresConfig.Spec.PostgresqlConf)

Expand Down Expand Up @@ -113,7 +113,7 @@ func TestPostgreSqlDeployWithPgConfig(t *testing.T) {
assert.NoError(t, svc.GetDesiredKubeObject(cluster, "cluster"))

sgPostgresConfig := &sgv1.SGPostgresConfig{}
assert.NoError(t, svc.GetDesiredKubeObject(sgPostgresConfig, "pg-conf"))
assert.NoError(t, svc.GetDesiredKubeObject(sgPostgresConfig, "pgsql-gc9x4-"+configResourceName))
assert.Contains(t, sgPostgresConfig.Spec.PostgresqlConf, "timezone")
assert.Equal(t, "Europe/Zurich", sgPostgresConfig.Spec.PostgresqlConf["timezone"])
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/comp-functions/functions/vshnpostgres/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func init() {
},
{
Name: "billing",
Execute: AddServiceBillingLabel,
Execute: AddBilling,
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/comp-functions/functions/vshnredis/billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/vshn/appcat/v4/pkg/comp-functions/runtime"
)

// AddServiceBillingLabel adds billingLabel to all the objects of a services that must be billed
func AddServiceBillingLabel(ctx context.Context, comp *v1.VSHNRedis, svc *runtime.ServiceRuntime) *xfnproto.Result {
// AddBilling enables billing for this service
func AddBilling(ctx context.Context, comp *v1.VSHNRedis, svc *runtime.ServiceRuntime) *xfnproto.Result {
err := svc.GetObservedComposite(comp)
if err != nil {
return runtime.NewFatalResult(fmt.Errorf("can't get composite: %w", err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/comp-functions/functions/vshnredis/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func init() {
},
{
Name: "billing",
Execute: AddServiceBillingLabel,
Execute: AddBilling,
},
},
})
Expand Down
Loading