forked from damomurf/systemd-credentials-vault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
32 lines (25 loc) · 862 Bytes
/
config.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
package main
import (
"os"
"github.com/go-yaml/yaml"
"github.com/pkg/errors"
)
type Config struct {
VaultServer *string `yaml:"vault_server"` // Address of the Vault server
SocketLocation string `yaml:"socket_location"` // The base path in which Unix sockets will be created
VaultApprole string `yaml:"vault_approle"` // The AppRole being queried
RoleId string `yaml:"role_id"` // The role ID
SecretIdPath string `yaml:"secret_id_path"` // The secret ID path
}
func newConfig(path string) (*Config, error) {
config := &Config{}
content, err := os.ReadFile(path) // the file is inside the local directory
if err != nil {
return nil, errors.Wrap(err, "opening config file")
}
err = yaml.Unmarshal(content, config)
if err != nil {
return nil, errors.Wrap(err, "parsing configuration yaml")
}
return config, nil
}