Skip to content

Commit

Permalink
Removed leftovers comments from hasAttrib function
Browse files Browse the repository at this point in the history
Signed-off-by: Theodor Mihalache <[email protected]>
  • Loading branch information
tmihalac committed Nov 21, 2024
1 parent d6b6f17 commit aea02e6
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions infra/feast-operator/internal/controller/services/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,29 +217,21 @@ func (feast *FeastServices) getSecret(secretRef string) (*corev1.Secret, error)

// Function to check if a struct has a specific field or field tag and sets the value in the field if empty
func hasAttrib(s interface{}, fieldName string, value interface{}) (bool, error) {
//t := reflect.TypeOf(s)
val := reflect.ValueOf(s)

// Check that the object is a pointer so we can modify it
if val.Kind() != reflect.Ptr || val.IsNil() {
return false, fmt.Errorf("expected a pointer to struct, got %v", val.Kind())
}

// Check if the value is a pointer and dereference it if necessary
//if t.Kind() == reflect.Ptr {
// t = t.Elem()
//}

val = val.Elem()
//t = t.Elem()

// Loop through the fields and check the tag
for i := 0; i < val.NumField(); i++ {
field := val.Field(i)
fieldType := val.Type().Field(i)

tagVal := fieldType.Tag.Get("yaml")
//tagVal := field.Tag.Get("yaml")

// Remove other metadata if exists
commaIndex := strings.Index(tagVal, ",")
Expand All @@ -250,12 +242,6 @@ func hasAttrib(s interface{}, fieldName string, value interface{}) (bool, error)

// Check if the field name or the tag value matches the one we're looking for
if strings.EqualFold(fieldType.Name, fieldName) || strings.EqualFold(tagVal, fieldName) {
//val := reflect.ValueOf(s).Field(i)

//// Check that the object is a pointer so we can modify it
//if val.Kind() != reflect.Ptr || val.IsNil() {
// return false, fmt.Errorf("expected a pointer to struct, got %v", val.Kind())
//}

// Ensure the field is settable
if !field.CanSet() {
Expand Down

0 comments on commit aea02e6

Please sign in to comment.