mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 13:41:36 +00:00
improve GetenvJson
This commit is contained in:
+2
-5
@@ -77,15 +77,12 @@ func (env *Env) GetList(key string) []string {
|
||||
return l
|
||||
}
|
||||
|
||||
func (env *Env) GetJson(key string) interface{} {
|
||||
func (env *Env) GetJson(key string, iface interface{}) error {
|
||||
sval := env.Get(key)
|
||||
if sval == "" {
|
||||
return nil
|
||||
}
|
||||
var m interface{}
|
||||
//Discard error on purpose
|
||||
json.Unmarshal([]byte(sval), &m)
|
||||
return m
|
||||
return json.Unmarshal([]byte(sval), iface)
|
||||
}
|
||||
|
||||
func (env *Env) SetJson(key string, value interface{}) error {
|
||||
|
||||
+2
-2
@@ -126,8 +126,8 @@ func (job *Job) GetenvList(key string) []string {
|
||||
return job.env.GetList(key)
|
||||
}
|
||||
|
||||
func (job *Job) GetenvJson(key string) interface{} {
|
||||
return job.env.GetJson(key)
|
||||
func (job *Job) GetenvJson(key string, iface interface{}) error {
|
||||
return job.env.GetJson(key, iface)
|
||||
}
|
||||
|
||||
func (job *Job) SetenvJson(key string, value interface{}) error {
|
||||
|
||||
Reference in New Issue
Block a user