...

Source file src/github.com/redhat-developer/odo/pkg/preference/machine_output.go

Documentation: github.com/redhat-developer/odo/pkg/preference

     1  package preference
     2  
     3  import (
     4  	"reflect"
     5  
     6  	"github.com/redhat-developer/odo/pkg/api"
     7  )
     8  
     9  func (o *preferenceInfo) NewPreferenceList() api.PreferenceList {
    10  	return api.PreferenceList{
    11  		Items: toPreferenceItems(*o),
    12  	}
    13  }
    14  
    15  func toPreferenceItems(prefInfo preferenceInfo) []api.PreferenceItem {
    16  	settings := prefInfo.OdoSettings
    17  	return []api.PreferenceItem{
    18  		{
    19  			Name:        UpdateNotificationSetting,
    20  			Value:       settings.UpdateNotification,
    21  			Default:     true,
    22  			Type:        getType(prefInfo.GetUpdateNotification()), // use the Getter here to determine type
    23  			Description: UpdateNotificationSettingDescription,
    24  		},
    25  		{
    26  			Name:        TimeoutSetting,
    27  			Value:       settings.Timeout,
    28  			Default:     DefaultTimeout,
    29  			Type:        getType(prefInfo.GetTimeout()),
    30  			Description: TimeoutSettingDescription,
    31  		},
    32  		{
    33  			Name:        PushTimeoutSetting,
    34  			Value:       settings.PushTimeout,
    35  			Default:     DefaultPushTimeout,
    36  			Type:        getType(prefInfo.GetPushTimeout()),
    37  			Description: PushTimeoutSettingDescription,
    38  		},
    39  		{
    40  			Name:        RegistryCacheTimeSetting,
    41  			Value:       settings.RegistryCacheTime,
    42  			Default:     DefaultRegistryCacheTime,
    43  			Type:        getType(prefInfo.GetRegistryCacheTime()),
    44  			Description: RegistryCacheTimeSettingDescription,
    45  		},
    46  		{
    47  			Name:        ConsentTelemetrySetting,
    48  			Value:       settings.ConsentTelemetry,
    49  			Default:     DefaultConsentTelemetrySetting,
    50  			Type:        getType(prefInfo.GetConsentTelemetry()),
    51  			Description: ConsentTelemetrySettingDescription,
    52  		},
    53  		{
    54  			Name:        EphemeralSetting,
    55  			Value:       settings.Ephemeral,
    56  			Default:     DefaultEphemeralSetting,
    57  			Type:        getType(prefInfo.GetEphemeral()),
    58  			Description: EphemeralSettingDescription,
    59  		},
    60  		{
    61  			Name:        ImageRegistrySetting,
    62  			Value:       settings.ImageRegistry,
    63  			Default:     "",
    64  			Type:        getType(prefInfo.GetImageRegistry()),
    65  			Description: ImageRegistrySettingDescription,
    66  		},
    67  	}
    68  }
    69  
    70  func getType(v interface{}) string {
    71  
    72  	rv := reflect.ValueOf(v)
    73  
    74  	if rv.Kind() == reflect.Ptr {
    75  		return rv.Elem().Kind().String()
    76  	}
    77  
    78  	return rv.Kind().String()
    79  }
    80  

View as plain text