-
Notifications
You must be signed in to change notification settings - Fork 43
/
secrets.go
42 lines (35 loc) · 900 Bytes
/
secrets.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
package flow
import (
"context"
"errors"
"github.com/direktiv/direktiv/pkg/refactor/database"
"github.com/direktiv/direktiv/pkg/refactor/datastore"
"github.com/direktiv/direktiv/pkg/refactor/filestore"
)
func (flow *flow) placeholdSecrets(ctx context.Context, tx *database.SQLStore, ns string, file *filestore.File) error {
data, err := tx.FileStore().ForFile(file).GetData(ctx)
if err != nil {
return err
}
wf, err := loadSource(data)
if err != nil {
return err
}
secretRefs := wf.GetSecretReferences()
for _, secretRef := range secretRefs {
_, err = tx.DataStore().Secrets().Get(ctx, ns, secretRef)
if errors.Is(err, datastore.ErrNotFound) {
err = tx.DataStore().Secrets().Set(ctx, &datastore.Secret{
Namespace: ns,
Name: secretRef,
Data: nil,
})
if err != nil {
continue
}
} else if err != nil {
continue
}
}
return nil
}