pass down field name
@@ -153,9 +153,9 @@ func applyProfile(config *latest.SkaffoldConfig, profile latest.Profile) error {
APIVersion: config.APIVersion,
Kind: config.Kind,
Pipeline: latest.Pipeline{
- Build: overlayProfileField(config.Build, profile.Build).(latest.BuildConfig),
- Deploy: overlayProfileField(config.Deploy, profile.Deploy).(latest.DeployConfig),
- Test: overlayProfileField(config.Test, profile.Test).([]*latest.TestCase),
+ Build: overlayProfileField("Build", config.Build, profile.Build).(latest.BuildConfig),
+ Deploy: overlayProfileField("Deploy", config.Deploy, profile.Deploy).(latest.DeployConfig),
+ Test: overlayProfileField("Test", config.Test, profile.Test).([]*latest.TestCase),
},
}
@@ -256,16 +256,16 @@ func overlayStructField(config interface{}, profile interface{}) interface{} {
for i := 0; i < profileValue.NumField(); i++ {
fieldType := t.Field(i)
- overlay := overlayProfileField(configValue.Field(i).Interface(), profileValue.Field(i).Interface())
+ overlay := overlayProfileField(fieldType.Name, configValue.Field(i).Interface(), profileValue.Field(i).Interface())
finalConfig.Elem().FieldByName(fieldType.Name).Set(reflect.ValueOf(overlay))
}
return reflect.Indirect(finalConfig).Interface() // since finalConfig is a pointer, dereference it
}
-func overlayProfileField(config interface{}, profile interface{}) interface{} {
+func overlayProfileField(fieldName string, config interface{}, profile interface{}) interface{} {
v := reflect.ValueOf(profile) // the profile itself
t := reflect.TypeOf(profile) // the type of the profile, used for getting struct field types
- logrus.Debugf("overlaying profile on config for field %s", t.Name())
+ logrus.Debugf("overlaying profile on config for field %s", fieldName)
switch v.Kind() {
case reflect.Struct:
// check the first field of the struct for a oneOf yamltag.
@@ -291,7 +291,7 @@ func overlayProfileField(config interface{}, profile interface{}) interface{} {
}
return v.Interface()
default:
- logrus.Warnf("Type mismatch in profile overlay for field %s of type %s; falling back to original config values", t.Name(), v.Kind())
+ logrus.Warnf("Type mismatch in profile overlay for field %s of type %s; falling back to original config values", fieldName, v.Kind())
return config
}
}
