Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix meta logs #1237

Merged
merged 2 commits into from
Jun 24, 2024
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
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
2 changes: 1 addition & 1 deletion nsxt/metadata/metadata_poly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ func TestFlattenSchemaToPolyStruct(t *testing.T) {
obj := testPolyStruct{}
elem := reflect.ValueOf(&obj).Elem()
err := SchemaToStruct(elem, d, testPolyStructFlattenExtSchema("struct", "PolyStruct"), "", nil)
assert.ErrorContainsf(t, err, "is alreay set", "expected error raised if same sdk is set twice")
assert.ErrorContainsf(t, err, "is already set", "expected error raised if same sdk is set twice")
})

t.Run("mixed list", func(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions nsxt/policy_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,8 @@ func getPolicyLbMonitorPortSchema() *schema.Schema {
Optional: true,
}
}

//lint:ignore U1000 Ignore unused function temporarily until used in autogenerated resource
func getVpcParentsFromContext(context utl.SessionContext) []string {
return []string{utl.DefaultOrgID, context.ProjectID, context.VPCID}
}
Loading