Skip to content

Commit

Permalink
Fix logs in reflect metadata library
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Khmelnitsky <[email protected]>
  • Loading branch information
annakhm committed Jun 20, 2024
1 parent 0683fa7 commit 4e3f8c3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nsxt/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ func StructToSchema(elem reflect.Value, d *schema.ResourceData, metadata map[str
if !elem.FieldByName(item.Metadata.SdkFieldName).IsValid() {
// FieldByName can't find the field by name
logger.Printf("[ERROR] %s skip key %s as %s not found in struct",
ctx, key, item.Metadata.SdkFieldName)
ctx, key, elem.Type())
err = fmt.Errorf("%s key %s not found in %s",
ctx, key, item.Metadata.SdkFieldName)
ctx, key, elem.Type())
return
}
if elem.FieldByName(item.Metadata.SdkFieldName).IsNil() {
Expand Down Expand Up @@ -274,9 +274,9 @@ func SchemaToStruct(elem reflect.Value, d *schema.ResourceData, metadata map[str
if !elem.FieldByName(item.Metadata.SdkFieldName).IsValid() {
// FieldByName can't find the field by name
logger.Printf("[WARN] %s skip key %s as %s not found in struct",
ctx, key, item.Metadata.SdkFieldName)
ctx, key, elem.Type())
err = fmt.Errorf("%s key %s not found in %s",
ctx, key, item.Metadata.SdkFieldName)
ctx, key, elem.Type())
return
}

Expand Down Expand Up @@ -680,7 +680,7 @@ func polyFlattenSchemaToStruct(ctx string, elem reflect.Value, key string, dataL
}
structElem := elem.FieldByName(item.Metadata.SdkFieldName)
if !structElem.IsZero() {
err = fmt.Errorf("%s %s is alreay set", ctx, item.Metadata.SdkFieldName)
err = fmt.Errorf("%s %s is already set", ctx, item.Metadata.SdkFieldName)
logger.Printf("[ERROR] %v", err)
return
}
Expand Down

0 comments on commit 4e3f8c3

Please sign in to comment.