Skip to content

Commit 1ac5eb4

Browse files
committed
feat: add additional annotations on storage service
1 parent 9ef293a commit 1ac5eb4

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

deployments/pulumi/pkg/config/config.go

+15
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ type StorageSource struct {
216216
Postgres *PostgresDatabase `json:"postgres" yaml:"postgres" jsonschema:"oneof_required=postgres"`
217217
}
218218

219+
type StorageService struct {
220+
// Annotations is the annotations for the service
221+
Annotations map[string]string `json:"annotations" yaml:"annotations"`
222+
}
223+
224+
func (s StorageService) toInput() storage.Service {
225+
return storage.Service{
226+
Annotations: pulumix.Val(s.Annotations),
227+
}
228+
}
229+
219230
type Storage struct {
220231
StorageSource
221232

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

225236
// DisableUpgrade is whether to disable upgrades for the database
226237
DisableUpgrade bool `json:"disable-upgrade" yaml:"disable-upgrade"`
238+
239+
// Service is the service configuration for the database
240+
Service StorageService `json:"service" yaml:"service"`
227241
}
228242

229243
func (s Storage) toInput() storage.Args {
@@ -232,6 +246,7 @@ func (s Storage) toInput() storage.Args {
232246
RDS: s.RDS.toInput(),
233247
ConnectivityDatabaseArgs: s.Connectivity.toInput(),
234248
DisableUpgrade: pulumix.Val(s.DisableUpgrade),
249+
Service: s.Service.toInput(),
235250
}
236251
}
237252

deployments/pulumi/pkg/storage/component.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ type databaseComponentFactory interface {
4848
setup(ctx *pulumi.Context, args factoryArgs, options ...pulumi.ResourceOption) (databaseComponent, error)
4949
}
5050

51+
type Service struct {
52+
Annotations pulumix.Input[map[string]string]
53+
}
54+
5155
type Args struct {
5256
Postgres *PostgresDatabaseArgs
5357
RDS *RDSDatabaseArgs
5458
ConnectivityDatabaseArgs ConnectivityDatabaseArgs
55-
DisableUpgrade pulumix.Output[bool]
59+
DisableUpgrade pulumix.Input[bool]
60+
Service Service
5661
}
5762

5863
func (args *Args) SetDefaults() {
@@ -109,8 +114,9 @@ func (cmp *Component) GetEnvVars() corev1.EnvVarArray {
109114
},
110115
corev1.EnvVarArgs{
111116
Name: pulumi.String("POSTGRES_URI"),
112-
Value: pulumi.Sprintf("postgres://$(POSTGRES_USERNAME):$(POSTGRES_PASSWORD)@%s:%d/%s?%s",
113-
cmp.DatabaseComponent.GetEndpoint(),
117+
Value: pulumi.Sprintf("postgres://$(POSTGRES_USERNAME):$(POSTGRES_PASSWORD)@%s.%s.svc.cluster.local:%d/%s?%s",
118+
cmp.Service.Metadata.Name().Elem(),
119+
cmp.Service.Metadata.Namespace().Elem(),
114120
cmp.DatabaseComponent.GetPort(),
115121
cmp.DatabaseComponent.GetDatabase(),
116122
pulumix.Apply2(
@@ -280,7 +286,6 @@ func NewComponent(ctx *pulumi.Context, name string, args ComponentArgs, options
280286
"username": cmp.DatabaseComponent.GetUsername().ToOutput(ctx.Context()).Untyped().(pulumi.StringOutput),
281287
"password": pulumix.Apply(cmp.DatabaseComponent.GetPassword(), func(password string) string {
282288
return url.QueryEscape(password)
283-
//cmp.DatabaseComponent.GetPassword().ToOutput(ctx.Context()).Untyped().(pulumi.StringOutput)
284289
}).Untyped().(pulumi.StringOutput),
285290
},
286291
}, pulumi.Parent(cmp))
@@ -297,6 +302,9 @@ func NewComponent(ctx *pulumi.Context, name string, args ComponentArgs, options
297302
Namespace: args.CommonArgs.Namespace.
298303
ToOutput(ctx.Context()).
299304
Untyped().(pulumi.StringOutput),
305+
Annotations: args.Service.Annotations.
306+
ToOutput(ctx.Context()).
307+
Untyped().(pulumi.StringMapOutput),
300308
},
301309
Spec: &corev1.ServiceSpecArgs{
302310
Type: pulumi.String("ExternalName"),
@@ -311,7 +319,7 @@ func NewComponent(ctx *pulumi.Context, name string, args ComponentArgs, options
311319
}
312320
}
313321

314-
args.DisableUpgrade.ApplyT(func(disableUpgrade bool) error {
322+
args.DisableUpgrade.ToOutput(ctx.Context()).ApplyT(func(disableUpgrade bool) error {
315323
if disableUpgrade {
316324
return nil
317325
}

0 commit comments

Comments
 (0)