summaryrefslogtreecommitdiff
path: root/service/env/service.go
blob: b072197108a88f62031096393c297c1c953a5acf (plain)
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 env

// ID contains default svc name.
const ID = "env"

// Service provides ability to map _ENV values from config file.
type Service struct {
	// Default is default set of values.
	Default map[string]string
	cfg     *Config
}

// NewService creates new env service instance for given rr version.
func NewService(version string) *Service {
	return &Service{Default: map[string]string{"rr": version}}
}

// Init must return configure svc and return true if svc hasStatus enabled. Must return error in case of
// misconfiguration. Services must not be used without proper configuration pushed first.
func (s *Service) Init(cfg *Config) (bool, error) {
	s.cfg = cfg
	for k, v := range s.Default {
		s.cfg.Values[k] = v
	}

	return true, nil
}

// GetEnv must return list of env variables.
func (s *Service) GetEnv() (map[string]string, error) {
	return s.cfg.Values, nil
}