-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
50 lines (41 loc) · 1.34 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2022 Namespace Labs Inc; All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package main
import (
"context"
"namespacelabs.dev/foundation/framework/kubernetes/kubedef"
"namespacelabs.dev/foundation/framework/provisioning"
"namespacelabs.dev/foundation/schema"
"namespacelabs.dev/foundation/std/secrets"
)
type tool struct{}
func main() {
h := provisioning.NewHandlers()
henv := h.MatchEnv(&schema.Environment{Runtime: "kubernetes"})
henv.HandleStack(tool{})
provisioning.Handle(h)
}
func (tool) Apply(ctx context.Context, r provisioning.StackRequest, out *provisioning.ApplyOutput) error {
collection, err := secrets.Collect(r.Focus.Server)
if err != nil {
return err
}
for _, secret := range collection.SecretsOf("namespacelabs.dev/foundation/universe/db/postgres/internal/gencreds") {
switch secret.Name {
case "postgres-password-file":
out.Extensions = append(out.Extensions, kubedef.ExtendContainer{
With: &kubedef.ContainerExtension{
Env: []*schema.BinaryConfig_EnvEntry{{
Name: "POSTGRES_PASSWORD_FILE",
Value: secret.FromPath,
}},
}})
default:
}
}
return nil
}
func (tool) Delete(ctx context.Context, r provisioning.StackRequest, out *provisioning.DeleteOutput) error {
return nil
}