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

feat: add additional annotations on storage service #825

Merged
merged 1 commit into from
Mar 27, 2025
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
15 changes: 15 additions & 0 deletions deployments/pulumi/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ type StorageSource struct {
Postgres *PostgresDatabase `json:"postgres" yaml:"postgres" jsonschema:"oneof_required=postgres"`
}

type StorageService struct {
// Annotations is the annotations for the service
Annotations map[string]string `json:"annotations" yaml:"annotations"`
}

func (s StorageService) toInput() storage.Service {
return storage.Service{
Annotations: pulumix.Val(s.Annotations),
}
}

type Storage struct {
StorageSource

Expand All @@ -224,6 +235,9 @@ type Storage struct {

// DisableUpgrade is whether to disable upgrades for the database
DisableUpgrade bool `json:"disable-upgrade" yaml:"disable-upgrade"`

// Service is the service configuration for the database
Service StorageService `json:"service" yaml:"service"`
}

func (s Storage) toInput() storage.Args {
Expand All @@ -232,6 +246,7 @@ func (s Storage) toInput() storage.Args {
RDS: s.RDS.toInput(),
ConnectivityDatabaseArgs: s.Connectivity.toInput(),
DisableUpgrade: pulumix.Val(s.DisableUpgrade),
Service: s.Service.toInput(),
}
}

Expand Down
18 changes: 13 additions & 5 deletions deployments/pulumi/pkg/storage/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ type databaseComponentFactory interface {
setup(ctx *pulumi.Context, args factoryArgs, options ...pulumi.ResourceOption) (databaseComponent, error)
}

type Service struct {
Annotations pulumix.Input[map[string]string]
}

type Args struct {
Postgres *PostgresDatabaseArgs
RDS *RDSDatabaseArgs
ConnectivityDatabaseArgs ConnectivityDatabaseArgs
DisableUpgrade pulumix.Output[bool]
DisableUpgrade pulumix.Input[bool]
Service Service
}

func (args *Args) SetDefaults() {
Expand Down Expand Up @@ -109,8 +114,9 @@ func (cmp *Component) GetEnvVars() corev1.EnvVarArray {
},
corev1.EnvVarArgs{
Name: pulumi.String("POSTGRES_URI"),
Value: pulumi.Sprintf("postgres://$(POSTGRES_USERNAME):$(POSTGRES_PASSWORD)@%s:%d/%s?%s",
cmp.DatabaseComponent.GetEndpoint(),
Value: pulumi.Sprintf("postgres://$(POSTGRES_USERNAME):$(POSTGRES_PASSWORD)@%s.%s.svc.cluster.local:%d/%s?%s",
cmp.Service.Metadata.Name().Elem(),
cmp.Service.Metadata.Namespace().Elem(),
cmp.DatabaseComponent.GetPort(),
cmp.DatabaseComponent.GetDatabase(),
pulumix.Apply2(
Expand Down Expand Up @@ -280,7 +286,6 @@ func NewComponent(ctx *pulumi.Context, name string, args ComponentArgs, options
"username": cmp.DatabaseComponent.GetUsername().ToOutput(ctx.Context()).Untyped().(pulumi.StringOutput),
"password": pulumix.Apply(cmp.DatabaseComponent.GetPassword(), func(password string) string {
return url.QueryEscape(password)
//cmp.DatabaseComponent.GetPassword().ToOutput(ctx.Context()).Untyped().(pulumi.StringOutput)
}).Untyped().(pulumi.StringOutput),
},
}, pulumi.Parent(cmp))
Expand All @@ -297,6 +302,9 @@ func NewComponent(ctx *pulumi.Context, name string, args ComponentArgs, options
Namespace: args.CommonArgs.Namespace.
ToOutput(ctx.Context()).
Untyped().(pulumi.StringOutput),
Annotations: args.Service.Annotations.
ToOutput(ctx.Context()).
Untyped().(pulumi.StringMapOutput),
},
Spec: &corev1.ServiceSpecArgs{
Type: pulumi.String("ExternalName"),
Expand All @@ -311,7 +319,7 @@ func NewComponent(ctx *pulumi.Context, name string, args ComponentArgs, options
}
}

args.DisableUpgrade.ApplyT(func(disableUpgrade bool) error {
args.DisableUpgrade.ToOutput(ctx.Context()).ApplyT(func(disableUpgrade bool) error {
if disableUpgrade {
return nil
}
Expand Down