Skip to content

Commit

Permalink
export FieldType function so it can be used outside cloud package
Browse files Browse the repository at this point in the history
  • Loading branch information
kl52752 committed Jul 15, 2024
1 parent d51d811 commit 87c036e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cloud/api/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func checkPostAccess(traits *FieldTraits, v reflect.Value) error {
if ft.Name == "NullFields" || ft.Name == "ForceSendFields" {
continue
}
fType := traits.fieldType(p.Field(ft.Name))
fType := traits.FieldType(p.Field(ft.Name))
fv := v.Field(i)
fp := p.Field(ft.Name)

Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/api/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (d *differ[T]) do(p Path, av, bv reflect.Value) error {
}

fp := p.Field(aft.Name)
switch d.traits.fieldType(fp) {
switch d.traits.FieldType(fp) {
case FieldTypeOutputOnly, FieldTypeSystem:
continue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/api/fill.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func fillNullAndForceSend(traits *FieldTraits, v reflect.Value) error {
if ft.Name == "NullFields" || ft.Name == "ForceSendFields" {
continue
}
fType := traits.fieldType(p.Field(ft.Name))
fType := traits.FieldType(p.Field(ft.Name))
fv := v.Field(i)

if fType == FieldTypeNonZeroValue {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cloud/api/type_trait.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ func (dt *FieldTraits) Clone() *FieldTraits {
}
}

func (dt *FieldTraits) fieldType(p Path) FieldType { return dt.fieldTrait(p).fType }
// FieldType returns field trait type for a given path
func (dt *FieldTraits) FieldType(p Path) FieldType { return dt.fieldTrait(p).fType }

func (dt *FieldTraits) fieldTrait(p Path) fieldTrait {
// TODO(bowei): this can be made very efficient with a tree, early bailout
Expand Down

0 comments on commit 87c036e

Please sign in to comment.