This is a huge commit, it does following things:
1. refactor kubesphere dependency service client creation, we can disable dependency by config 2. dependencies can be configured by configuration file 3. refactor cmd package using cobra.Command, so we can use hypersphere to invoke command sepearately. Later we only need to build one image to contains all kubesphere core components. One command to rule them all! 4. live reloading configuration currently not implemented
This commit is contained in:
@@ -13,7 +13,9 @@ limitations under the License.
|
||||
|
||||
package reflectutils
|
||||
|
||||
import "reflect"
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func In(value interface{}, container interface{}) bool {
|
||||
containerValue := reflect.ValueOf(container)
|
||||
@@ -33,3 +35,24 @@ func In(value interface{}, container interface{}) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Override(left interface{}, right interface{}) {
|
||||
if left == nil || right == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if reflect.ValueOf(left).Type().Kind() != reflect.Ptr ||
|
||||
reflect.ValueOf(right).Type().Kind() != reflect.Ptr {
|
||||
return
|
||||
}
|
||||
|
||||
old := reflect.ValueOf(left).Elem()
|
||||
new := reflect.ValueOf(right).Elem()
|
||||
|
||||
for i := 0; i < old.NumField(); i++ {
|
||||
val := new.Field(i).Interface()
|
||||
if !reflect.DeepEqual(val, reflect.Zero(reflect.TypeOf(val)).Interface()) {
|
||||
old.Field(i).Set(reflect.ValueOf(val))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user