Skip to content

Commit

Permalink
Adding logic to ignore set field
Browse files Browse the repository at this point in the history
  • Loading branch information
Vandita2020 committed Sep 25, 2023
1 parent 75a2dbf commit 50067ec
Showing 1 changed file with 19 additions and 47 deletions.
66 changes: 19 additions & 47 deletions pkg/generate/code/set_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,23 +328,6 @@ func SetSDK(
indent = "\t" + indent
}

//check ignore
// fieldConfigs := cfg.GetFieldConfigs(r.Names.Original)
flag := false
if f.FieldConfig != nil {
if f.FieldConfig.Set != nil {
set := f.FieldConfig.Set
for _, value := range set {
if value.Ignore == true {
flag = true
}
}
}
}
if flag {
continue
}

out += fmt.Sprintf(
"%sif %s != nil {\n", indent, sourceAdaptedVarName,
)
Expand Down Expand Up @@ -1117,37 +1100,26 @@ func SetSDKForStruct(
sourceAdaptedVarName := sourceVarName + "." + cleanMemberName
memberFieldPath := sourceFieldPath + "." + cleanMemberName

// flag := false
// if r.Fields[targetFieldName] != nil {
// if r.Fields[targetFieldName].MemberFields[memberName] != nil {
// if r.Fields[targetFieldName].MemberFields[memberName].FieldConfig != nil {
// if r.Fields[targetFieldName].MemberFields[memberName].FieldConfig.Set != nil {
// set := r.Fields[targetFieldName].MemberFields[memberName].FieldConfig.Set
// for _, value := range set {
// if value.Ignore == true {
// flag = true
// }
// }
// }
// }
// }
// }
// if r.Fields[memberName] != nil {
// if r.Fields[memberName].FieldConfig != nil {
// if r.Fields[memberName].FieldConfig.Set != nil {
// set := r.Fields[memberName].FieldConfig.Set
// for _, value := range set {
// if value.Ignore == true {
// flag = true
// }
// }
// }
// }
// }
// todo: To make `ignore` functionality work for all fields that has `ignore` set to `true`,
// we need to add the below logic inside `SetSDK` function.

// if flag {
// continue
// }
// To check if the field member has `ignore` set to `true`.
// This condition currently applies only for members of a field whose shape is `structure`
if r.Fields[targetFieldName] != nil {
memberField := r.Fields[targetFieldName].MemberFields[memberName]
if memberField != nil && memberField.FieldConfig != nil && memberField.FieldConfig.Set != nil {
set := memberField.FieldConfig.Set
shouldIgnore := false
for _, value := range set {
if value.Ignore == true {
shouldIgnore = true
}
}
if shouldIgnore {
continue
}
}
}

out += fmt.Sprintf(
"%sif %s != nil {\n", indent, sourceAdaptedVarName,
Expand Down

0 comments on commit 50067ec

Please sign in to comment.