Update vmware/govmomi godeps
This commit is contained in:
19
vendor/github.com/vmware/govmomi/object/custom_fields_manager.go
generated
vendored
19
vendor/github.com/vmware/govmomi/object/custom_fields_manager.go
generated
vendored
@@ -102,7 +102,9 @@ func (m CustomFieldsManager) Set(ctx context.Context, entity types.ManagedObject
|
||||
return err
|
||||
}
|
||||
|
||||
func (m CustomFieldsManager) Field(ctx context.Context) ([]types.CustomFieldDef, error) {
|
||||
type CustomFieldDefList []types.CustomFieldDef
|
||||
|
||||
func (m CustomFieldsManager) Field(ctx context.Context) (CustomFieldDefList, error) {
|
||||
var fm mo.CustomFieldsManager
|
||||
|
||||
err := m.Properties(ctx, m.Reference(), []string{"field"}, &fm)
|
||||
@@ -113,19 +115,19 @@ func (m CustomFieldsManager) Field(ctx context.Context) ([]types.CustomFieldDef,
|
||||
return fm.Field, nil
|
||||
}
|
||||
|
||||
func (m CustomFieldsManager) FindKey(ctx context.Context, key string) (int32, error) {
|
||||
func (m CustomFieldsManager) FindKey(ctx context.Context, name string) (int32, error) {
|
||||
field, err := m.Field(ctx)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
for _, def := range field {
|
||||
if def.Name == key {
|
||||
if def.Name == name {
|
||||
return def.Key, nil
|
||||
}
|
||||
}
|
||||
|
||||
k, err := strconv.Atoi(key)
|
||||
k, err := strconv.Atoi(name)
|
||||
if err == nil {
|
||||
// assume literal int key
|
||||
return int32(k), nil
|
||||
@@ -133,3 +135,12 @@ func (m CustomFieldsManager) FindKey(ctx context.Context, key string) (int32, er
|
||||
|
||||
return -1, ErrKeyNameNotFound
|
||||
}
|
||||
|
||||
func (l CustomFieldDefList) ByKey(key int32) *types.CustomFieldDef {
|
||||
for _, def := range l {
|
||||
if def.Key == key {
|
||||
return &def
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user