github.com/gocrane/crane@v0.11.0/pkg/recommendation/recommender/apis/recommender.go (about) 1 package apis 2 3 import ( 4 "strconv" 5 "time" 6 ) 7 8 func (r Recommender) GetConfigFloat(key string, def float64) (float64, error) { 9 if value, exists := r.Config[key]; exists { 10 return strconv.ParseFloat(value, 64) 11 } 12 return def, nil 13 } 14 15 func (r Recommender) GetConfigInt(key string, def int64) (int64, error) { 16 if value, exists := r.Config[key]; exists { 17 return strconv.ParseInt(value, 10, 64) 18 } 19 return def, nil 20 } 21 22 func (r Recommender) GetConfigBool(key string, def bool) (bool, error) { 23 if value, exists := r.Config[key]; exists { 24 return strconv.ParseBool(value) 25 } 26 return def, nil 27 } 28 29 func (r Recommender) GetConfigString(key string, def string) string { 30 if value, exists := r.Config[key]; exists { 31 return value 32 } 33 return def 34 } 35 36 func (r Recommender) GetConfigDuration(key string, def time.Duration) (time.Duration, error) { 37 if value, exists := r.Config[key]; exists { 38 return time.ParseDuration(value) 39 } 40 return def, nil 41 }