mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 13:11:30 +00:00
move commit to job
This commit is contained in:
+15
-7
@@ -1,17 +1,16 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"io"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Env []string
|
||||
|
||||
|
||||
func (env *Env) Get(key string) (value string) {
|
||||
// FIXME: use Map()
|
||||
for _, kv := range *env {
|
||||
@@ -44,7 +43,6 @@ func (env *Env) GetBool(key string) (value bool) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
func (env *Env) SetBool(key string, value bool) {
|
||||
if value {
|
||||
env.Set(key, "1")
|
||||
@@ -79,6 +77,17 @@ func (env *Env) GetList(key string) []string {
|
||||
return l
|
||||
}
|
||||
|
||||
func (env *Env) GetJson(key string) interface{} {
|
||||
sval := env.Get(key)
|
||||
if sval == "" {
|
||||
return nil
|
||||
}
|
||||
var m interface{}
|
||||
//Discard error on purpose
|
||||
json.Unmarshal([]byte(sval), &m)
|
||||
return m
|
||||
}
|
||||
|
||||
func (env *Env) SetJson(key string, value interface{}) error {
|
||||
sval, err := json.Marshal(value)
|
||||
if err != nil {
|
||||
@@ -218,4 +227,3 @@ func (env *Env) Map() map[string]string {
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,10 @@ 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) SetenvJson(key string, value interface{}) error {
|
||||
return job.env.SetJson(key, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user