go.mod: update osbuild/images to v0.69.0

This commit is contained in:
Achilleas Koutsou 2024-07-02 14:42:15 +02:00
parent 1cc90c6a0b
commit 8ac80e8abc
611 changed files with 28281 additions and 32629 deletions

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2023 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -210,7 +210,7 @@ type CustomizationSpecManager struct {
Self types.ManagedObjectReference `json:"self"`
Info []types.CustomizationSpecInfo `json:"info"`
EncryptionKey []byte `json:"encryptionKey"`
EncryptionKey types.ByteSlice `json:"encryptionKey"`
}
func (m CustomizationSpecManager) Reference() types.ManagedObjectReference {

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014-2015 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -75,16 +75,19 @@ func ApplyPropertyChange(obj Reference, changes []types.PropertyChange) {
v := reflect.ValueOf(obj)
for _, p := range changes {
rv, ok := t.props[p.Name]
if !ok {
// For now, skip unknown properties allowing PC updates to be triggered
// for partial updates (e.g. extensionList["my.extension"]).
// Ultimately we should support partial updates by assigning the value
// reflectively in assignValue.
continue
var field Field
if !field.FromString(p.Name) {
panic(p.Name + ": invalid property path")
}
assignValue(v, rv, reflect.ValueOf(p.Val))
rv, ok := t.props[field.Path]
if !ok {
panic(field.Path + ": property not found")
}
if field.Key == nil { // Key is only used for notifications
assignValue(v, rv, reflect.ValueOf(p.Val))
}
}
}

View file

@ -1,11 +1,11 @@
/*
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
Copyright (c) 2014-2024 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@ -20,6 +20,7 @@ import (
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
"sync"
@ -34,6 +35,9 @@ type typeInfo struct {
// Map property names to field indices.
props map[string][]int
// Use base type for interface indices.
base bool
}
var typeInfoLock sync.RWMutex
@ -62,12 +66,22 @@ func typeInfoForType(tname string) *typeInfo {
return ti
}
func newTypeInfo(typ reflect.Type) *typeInfo {
func baseType(ftyp reflect.Type) reflect.Type {
base := strings.TrimPrefix(ftyp.Name(), "Base")
if kind, ok := types.TypeFunc()(base); ok {
return kind
}
return ftyp
}
func newTypeInfo(typ reflect.Type, base ...bool) *typeInfo {
t := typeInfo{
typ: typ,
props: make(map[string][]int),
}
if len(base) == 1 {
t.base = base[0]
}
t.build(typ, "", []int{})
return &t
@ -155,6 +169,15 @@ func (t *typeInfo) build(typ reflect.Type, fn string, fi []int) {
if ftyp.Kind() == reflect.Struct {
t.build(ftyp, fnc, fic)
}
// Indexed property path may traverse into array element fields.
// When interface, use the base type to index fields.
// For example, BaseVirtualDevice:
// config.hardware.device[4000].deviceInfo.label
if t.base && ftyp.Kind() == reflect.Interface {
base := baseType(ftyp)
t.build(base, fnc, fic)
}
}
}
@ -164,7 +187,14 @@ var nilValue reflect.Value
// slice of field indices. It recurses into the struct until it finds the field
// specified by the indices. It creates new values for pointer types where
// needed.
func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
func assignValue(val reflect.Value, fi []int, pv reflect.Value, field ...string) {
// Indexed property path can only use base types
if val.Kind() == reflect.Interface {
base := baseType(val.Type())
val.Set(reflect.New(base))
val = val.Elem()
}
// Create new value if necessary.
if val.Kind() == reflect.Ptr {
if val.IsNil() {
@ -230,6 +260,43 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
rv.Set(pv)
} else if rt.ConvertibleTo(pt) {
rv.Set(pv.Convert(rt))
} else if rt.Kind() == reflect.Slice {
// Indexed array value
path := field[0]
isInterface := rt.Elem().Kind() == reflect.Interface
if len(path) == 0 {
// Append item (pv) directly to the array, converting to pointer if interface
if isInterface {
npv := reflect.New(pt)
npv.Elem().Set(pv)
pv = npv
pt = pv.Type()
}
} else {
// Construct item to be appended to the array, setting field within to value of pv
var item reflect.Value
if isInterface {
base := baseType(rt.Elem())
item = reflect.New(base)
} else {
item = reflect.New(rt.Elem())
}
field := newTypeInfo(item.Type(), true)
if ix, ok := field.props[path]; ok {
assignValue(item, ix, pv)
}
if rt.Elem().Kind() == reflect.Struct {
pv = item.Elem()
} else {
pv = item
}
pt = pv.Type()
}
rv.Set(reflect.Append(rv, pv))
} else {
panic(fmt.Sprintf("cannot assign %q (%s) to %q (%s)", rt.Name(), rt.Kind(), pt.Name(), pt.Kind()))
}
@ -237,7 +304,7 @@ func assignValue(val reflect.Value, fi []int, pv reflect.Value) {
return
}
assignValue(rv, fi, pv)
assignValue(rv, fi, pv, field...)
}
var arrayOfRegexp = regexp.MustCompile("ArrayOf(.*)$")
@ -250,11 +317,14 @@ func (t *typeInfo) LoadFromObjectContent(o types.ObjectContent) (reflect.Value,
assignValue(v, t.self, reflect.ValueOf(o.Obj))
for _, p := range o.PropSet {
rv, ok := t.props[p.Name]
var field Field
field.FromString(p.Name)
rv, ok := t.props[field.Path]
if !ok {
continue
}
assignValue(v, rv, reflect.ValueOf(p.Val))
assignValue(v, rv, reflect.ValueOf(p.Val), field.Item)
}
return v, nil
@ -264,3 +334,70 @@ func IsManagedObjectType(kind string) bool {
_, ok := t[kind]
return ok
}
// Field of a ManagedObject in string form.
type Field struct {
Path string
Key any
Item string
}
func (f *Field) String() string {
if f.Key == nil {
return f.Path
}
var key, item string
switch f.Key.(type) {
case string:
key = fmt.Sprintf("%q", f.Key)
default:
key = fmt.Sprintf("%d", f.Key)
}
if f.Item != "" {
item = "." + f.Item
}
return fmt.Sprintf("%s[%s]%s", f.Path, key, item)
}
func (f *Field) FromString(spec string) bool {
s := strings.SplitN(spec, "[", 2)
f.Path = s[0]
f.Key = nil
f.Item = ""
if len(s) == 1 {
return true
}
parts := strings.SplitN(s[1], "]", 2)
if len(parts) != 2 {
return false
}
ix := strings.Trim(parts[0], `"`)
if ix == parts[0] {
v, err := strconv.ParseInt(ix, 0, 32)
if err != nil {
return false
}
f.Key = int32(v)
} else {
f.Key = ix
}
if parts[1] == "" {
return true
}
if parts[1][0] != '.' {
return false
}
f.Item = parts[1][1:]
return true
}