Skip to content

Commit

Permalink
new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vandita2020 committed Sep 25, 2023
1 parent 0d29975 commit 75a2dbf
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 56 deletions.
10 changes: 0 additions & 10 deletions pkg/config/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
package config

import (
"encoding/json"
"fmt"
"strings"

awssdkmodel "github.com/aws/aws-sdk-go/private/model/api"
Expand Down Expand Up @@ -526,14 +524,6 @@ func (c *Config) GetResourceFieldName(
if !ok {
return origFieldName
}

if resourceName == "Function" {
if origFieldName == "Code" {
t, _ := json.Marshal(rConfig.Renames)
fmt.Println("rConfig.Renames", string(t))
}
}

if rConfig.Renames == nil {
return origFieldName
}
Expand Down
87 changes: 49 additions & 38 deletions pkg/generate/code/set_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package code

import (
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down Expand Up @@ -115,17 +114,6 @@ func SetSDK(
}
inputShape := op.InputRef.Shape

if r.Names.Camel == "Function" {
_, ok := r.SpecFields["Code"]
if ok {
// k, _ := json.Marshal(op.InputRef.Shape)
// fmt.Println("InputRef.Shape", string(k)) // createFunction, getFunction, deleteFunction

i, _ := json.Marshal(op.InputRef.Shape.MemberRefs["Attributes"])
fmt.Println("InputRef.Shape.MemeberRefs[Attributes]", string(i)) // null
}
}

if inputShape == nil {
return ""
}
Expand Down Expand Up @@ -191,18 +179,6 @@ func SetSDK(

opConfig, override := cfg.GetOverrideValues(op.ExportedName)

if r.Names.Camel == "Function" {
_, ok := r.SpecFields["Code"]
if ok {
opConfig, override := cfg.GetOverrideValues(op.ExportedName)

fmt.Println("opConfig is", opConfig) // map[]
fmt.Println("override is", override) // false

fmt.Println("Member names are", inputShape.MemberNames())
}
}

// for create op: Member Names have Code
for memberIndex, memberName := range inputShape.MemberNames() {
if r.UnpacksAttributesMap() && memberName == "Attributes" {
Expand Down Expand Up @@ -267,20 +243,6 @@ func SetSDK(
}

inSpec, inStatus := r.HasMember(fieldName, op.ExportedName)
if r.Names.Camel == "Function" {
_, ok := r.SpecFields["Code"]
// d, _ := json.Marshal(r.SpecFields["Code"])
// fmt.Println("Fields are", string(d))

if ok {
_, ok2 := r.SpecFields["Code"].MemberFields["S3SHA256"]
if ok2 {
fmt.Println("spec status", inSpec, inStatus)
}
fmt.Println("spec status", inSpec, inStatus)
}

}

if inSpec {
sourceAdaptedVarName += cfg.PrefixConfig.SpecField
Expand Down Expand Up @@ -366,6 +328,23 @@ 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 @@ -1138,6 +1117,38 @@ 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
// }
// }
// }
// }
// }

// if flag {
// continue
// }

out += fmt.Sprintf(
"%sif %s != nil {\n", indent, sourceAdaptedVarName,
)
Expand Down
8 changes: 0 additions & 8 deletions pkg/model/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,6 @@ func (r *CRD) GetMatchingInputShapeFieldName(opType OpType, sdkField string) str
if f.FieldConfig == nil {
continue
}
if r.Names.Camel == "Function" && f.Names.Camel == "Code" {
// a, _ := json.Marshal(f.FieldConfig)
// fmt.Println("f.Fieldconfig", string(a))

// b, _ := json.Marshal(f.FieldConfig.Set)
// fmt.Println("f.fieldConfig.Set", string(b))

}
rmMethod := ResourceManagerMethodFromOpType(opType)
for _, setCfg := range f.FieldConfig.Set {
if setCfg == nil {
Expand Down

0 comments on commit 75a2dbf

Please sign in to comment.