This commit updates to images v0.117.0 so that the cross-distro.sh test works again (images removed fedora-39.json in main but the uses the previous version of images that includes fedora-39 so there is a mismatch (we should look into if there is a way to get github.com/osbuild/images@latest instead of main in the cross-arch test). It also updates all the vendor stuff that got pulled via the new images release (which is giantonormous). This update requires updating the Go version to 1.22.8
69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package smithy
|
|
|
|
import "maps"
|
|
|
|
// PropertiesReader provides an interface for reading metadata from the
|
|
// underlying metadata container.
|
|
type PropertiesReader interface {
|
|
Get(key any) any
|
|
}
|
|
|
|
// Properties provides storing and reading metadata values. Keys may be any
|
|
// comparable value type. Get and Set will panic if a key is not comparable.
|
|
//
|
|
// The zero value for a Properties instance is ready for reads/writes without
|
|
// any additional initialization.
|
|
type Properties struct {
|
|
values map[any]any
|
|
}
|
|
|
|
// Get attempts to retrieve the value the key points to. Returns nil if the
|
|
// key was not found.
|
|
//
|
|
// Panics if key type is not comparable.
|
|
func (m *Properties) Get(key any) any {
|
|
m.lazyInit()
|
|
return m.values[key]
|
|
}
|
|
|
|
// Set stores the value pointed to by the key. If a value already exists at
|
|
// that key it will be replaced with the new value.
|
|
//
|
|
// Panics if the key type is not comparable.
|
|
func (m *Properties) Set(key, value any) {
|
|
m.lazyInit()
|
|
m.values[key] = value
|
|
}
|
|
|
|
// Has returns whether the key exists in the metadata.
|
|
//
|
|
// Panics if the key type is not comparable.
|
|
func (m *Properties) Has(key any) bool {
|
|
m.lazyInit()
|
|
_, ok := m.values[key]
|
|
return ok
|
|
}
|
|
|
|
// SetAll accepts all of the given Properties into the receiver, overwriting
|
|
// any existing keys in the case of conflicts.
|
|
func (m *Properties) SetAll(other *Properties) {
|
|
if other.values == nil {
|
|
return
|
|
}
|
|
|
|
m.lazyInit()
|
|
for k, v := range other.values {
|
|
m.values[k] = v
|
|
}
|
|
}
|
|
|
|
// Values returns a shallow clone of the property set's values.
|
|
func (m *Properties) Values() map[any]any {
|
|
return maps.Clone(m.values)
|
|
}
|
|
|
|
func (m *Properties) lazyInit() {
|
|
if m.values == nil {
|
|
m.values = map[any]any{}
|
|
}
|
|
}
|