-
Notifications
You must be signed in to change notification settings - Fork 0
/
zpu_config.go
57 lines (48 loc) · 1.28 KB
/
zpu_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Copyright © 2019 Hamed Yousefi <hdyousefi@gmail.com>.
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file.
*
* User: Hamed Yousefi
* Email: hdyousefi@gmail.com
* Date: 2/24/19
* Time: 1:24 PM
*
* Description:
*
*/
package config
import (
"github.com/yahoo/athenz/utils/zpe-updater"
"github.com/hamed-yousefi/athenz-agent/common"
)
const (
LogFile = "agent.out"
LogDir = "logs"
)
var (
ZpuConfig = new(ZpuConfiguration)
)
type (
ZpuConfiguration struct {
// Yahoo zpu configuration
Properties *zpu.ZpuConfiguration
}
)
// LoadGlobalZpuConfig loads config file from input path into the global
// variable ZpuConfig.
func LoadGlobalZpuConfig(athenzConfPath, zpuConfPath string) error {
return LoadZpuConfig(ZpuConfig, athenzConfPath, zpuConfPath)
}
// LoadZpuConfig reads config file from a specific address and loads it into
// a ZpuConfiguration object.
func LoadZpuConfig(zpuConfig *ZpuConfiguration, athenzConfPath, zpuConfPath string) error {
var err error
// load ZPU configuration using Yahoo zpe-updater
zpuConfig.Properties, err = zpu.NewZpuConfiguration(".", athenzConfPath, zpuConfPath)
if err != nil {
return common.Errorf("unable to get zpu configuration, error: %s", err.Error())
}
return nil
}