Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/harbor/root/context/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func deleteValueInConfig(
func deleteNestedValue(obj interface{}, path []string, actualSegments *[]string) error {
// We require obj to be a pointer to a struct so we can modify it.
val := reflect.ValueOf(obj)
if val.Kind() != reflect.Ptr {
if val.Kind() != reflect.Pointer {
return fmt.Errorf("object must be a pointer to a struct, got %s", val.Kind())
}
val = val.Elem() // dereference pointer
Expand Down Expand Up @@ -219,12 +219,12 @@ func deleteNestedValue(obj interface{}, path []string, actualSegments *[]string)
// If this is NOT the last path segment, move deeper
if i < len(path)-1 {
// If the field is a pointer and nil, we can't go deeper
if fieldValue.Kind() == reflect.Ptr && fieldValue.IsNil() {
if fieldValue.Kind() == reflect.Pointer && fieldValue.IsNil() {
return fmt.Errorf("field '%s' is nil and cannot be traversed", field.Name)
}
// Descend
val = fieldValue
if val.Kind() == reflect.Ptr {
if val.Kind() == reflect.Pointer {
val = val.Elem()
}
continue
Expand Down
4 changes: 2 additions & 2 deletions cmd/harbor/root/context/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func getNestedValue(obj interface{}, path []string, actualSegments *[]string) (i

for _, key := range path {
// If it's a pointer, dereference
if current.Kind() == reflect.Ptr {
if current.Kind() == reflect.Pointer {
current = current.Elem()
}
if current.Kind() != reflect.Struct {
Expand Down Expand Up @@ -189,7 +189,7 @@ func getNestedValue(obj interface{}, path []string, actualSegments *[]string) (i
}

// Finally, if we ended on a pointer, dereference it
if current.Kind() == reflect.Ptr {
if current.Kind() == reflect.Pointer {
current = current.Elem()
}
return current.Interface(), nil
Expand Down
6 changes: 3 additions & 3 deletions cmd/harbor/root/context/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func setValueInConfig(
func setNestedValue(obj interface{}, path []string, newValue string, actualSegments *[]string) error {
// We require obj to be a pointer to a struct so we can modify it.
val := reflect.ValueOf(obj)
if val.Kind() != reflect.Ptr {
if val.Kind() != reflect.Pointer {
return fmt.Errorf("object must be a pointer to a struct, got %s", val.Kind())
}
val = val.Elem() // dereference pointer
Expand Down Expand Up @@ -174,13 +174,13 @@ func setNestedValue(obj interface{}, path []string, newValue string, actualSegme
// If this is NOT the last path segment, move deeper
if i < len(path)-1 {
// If the field is a pointer and nil, allocate a new instance
if fieldValue.Kind() == reflect.Ptr && fieldValue.IsNil() {
if fieldValue.Kind() == reflect.Pointer && fieldValue.IsNil() {
newElem := reflect.New(fieldValue.Type().Elem())
fieldValue.Set(newElem)
}
// Descend
val = fieldValue
if val.Kind() == reflect.Ptr {
if val.Kind() == reflect.Pointer {
val = val.Elem()
}
continue
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/goharbor/harbor-cli

go 1.26.2
go 1.26.3

require (
github.com/atotto/clipboard v0.1.4
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func ParseHarborErrorMsg(err error) string {
}

val := reflect.ValueOf(err)
if val.Kind() == reflect.Ptr {
if val.Kind() == reflect.Pointer {
val = val.Elem()
}
field := val.FieldByName("Payload")
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func ExtractConfigValues[T ConfigType](cfg T) map[string]any {
field := v.Field(i)
fieldName := t.Field(i).Name
// Skip nil pointers
if field.Kind() == reflect.Ptr && field.IsNil() {
if field.Kind() == reflect.Pointer && field.IsNil() {
continue
}
configItem := field.Interface()
Expand All @@ -154,7 +154,7 @@ func ExtractConfigValues[T ConfigType](cfg T) map[string]any {
default:
// Handle generic pointer types using reflection
val := reflect.ValueOf(configItem)
if val.Kind() == reflect.Ptr && !val.IsNil() {
if val.Kind() == reflect.Pointer && !val.IsNil() {
deref := val.Elem()
// Only include non-zero values
if deref.IsValid() && !deref.IsZero() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/views/info/list/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func renderSectionTable(title string, data interface{}) {
func createRows(data interface{}, rows *[]table.Row) {
val := reflect.ValueOf(data)

if val.Kind() == reflect.Ptr {
if val.Kind() == reflect.Pointer {
val = val.Elem()
}

Expand All @@ -127,7 +127,7 @@ func createRows(data interface{}, rows *[]table.Row) {
fieldType := typ.Field(i)
fieldName := fieldType.Name

if field.Kind() == reflect.Ptr && !field.IsNil() {
if field.Kind() == reflect.Pointer && !field.IsNil() {
field = field.Elem()
}

Expand Down
Loading