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

tag v0.145.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.145.0

----------------
  * github: run dependabot gomod action weekly (osbuild/images#1476)
    * Author: Achilleas Koutsou, Reviewers: Lukáš Zapletal

— Somewhere on the Internet, 2025-05-12

---

tag v0.146.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.146.0

----------------
  * Fixes for ESP partition: Make optional, set label (osbuild/images#1525)
    * Author: Alexander Larsson, Reviewers: Achilleas Koutsou, Brian C. Lane
  * Initial automotive work: custom selinux policy, separate build container for bootc, and ext4 verity (osbuild/images#1519)
    * Author: Alexander Larsson, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * Update snapshots to 20250512 (osbuild/images#1515)
    * Author: SchutzBot, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * disk: make auto-generated /boot 1 GiB big (osbuild/images#1499)
    * Author: Ondřej Budai, Reviewers: Achilleas Koutsou, Michael Vogt
  * distro.yaml: Clean up yamllint errors and warnings (osbuild/images#1523)
    * Author: Brian C. Lane, Reviewers: Michael Vogt, Simon de Vlieger
  * distro/rhel9: make /boot 1 GiB everywhere (osbuild/images#1498)
    * Author: Ondřej Budai, Reviewers: Michael Vogt, Simon de Vlieger
  * distro: move disk/container image types into pure YAML (COMPOSER-2533) (osbuild/images#1508)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * fedora: move all image types into pure YAML (osbuild/images#1514)
    * Author: Michael Vogt, Reviewers: Brian C. Lane, Simon de Vlieger
  * fsnode: fix go-1.24 errors  (osbuild/images#1521)
    * Author: Michael Vogt, Reviewers: Ondřej Budai, Tomáš Hozza
  * osbuild: add JSON/YAML unmarshal to UdevRulesStageOptions (osbuild/images#1489)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * test: Run more distro tests in parallel (osbuild/images#1483)
    * Author: Brian C. Lane, Reviewers: Michael Vogt, Simon de Vlieger

— Somewhere on the Internet, 2025-05-19

---

tag v0.147.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.147.0

----------------
  * Add support for setting partition uuid and label (osbuild/images#1543)
    * Author: Alexander Larsson, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * Cleanup of new APIs (mkfs options and build container) (osbuild/images#1526)
    * Author: Alexander Larsson, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * distro/rhel: remove the user/group warnings for edge-commits (osbuild/images#1538)
    * Author: Achilleas Koutsou, Reviewers: Brian C. Lane, Simon de Vlieger

— Somewhere on the Internet, 2025-05-20

---

tag v0.148.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.148.0

----------------
  * Makefile: add vet command to check for consistent struct tags (osbuild/images#1554)
    * Author: Michael Vogt, Reviewers: Lukáš Zapletal, Simon de Vlieger
  * disk: tiny tweaks for the new MkfsOptions support (osbuild/images#1545)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Alexander Larsson, Lukáš Zapletal
  * fedora/many: increase `/boot` to 1 GiB (HMS-8604) (osbuild/images#1557)
    * Author: Simon de Vlieger, Reviewers: Achilleas Koutsou, Ondřej Budai
  * fedora/wsl: include `wsl-setup` (HMS-8573) (osbuild/images#1550)
    * Author: Simon de Vlieger, Reviewers: Brian C. Lane, Michael Vogt
  * fedora: add `anaconda.ModuleUsers` to ImageInstallerImage (osbuild/images#1558)
    * Author: Michael Vogt, Reviewers: Brian C. Lane, Simon de Vlieger
  * fedora: implement setting of the RootfsType via YAML (osbuild/images#1544)
    * Author: Michael Vogt, Reviewers: Brian C. Lane, Simon de Vlieger
  * rhel10: move ImageConfig into pure YAML (osbuild/images#1542)
    * Author: Michael Vogt, Reviewers: Brian C. Lane, Simon de Vlieger

— Somewhere on the Internet, 2025-05-26

---
This commit is contained in:
Achilleas Koutsou 2025-05-27 16:35:51 +02:00
parent 12dd0b0be4
commit c77ca66191
88 changed files with 5093 additions and 4979 deletions

View file

@ -1,6 +1,12 @@
package fsnode
import "os"
import (
"bytes"
"encoding/json"
"os"
"github.com/osbuild/images/internal/common"
)
type Directory struct {
baseFsNode
@ -14,6 +20,27 @@ func (d *Directory) EnsureParentDirs() bool {
return d.ensureParentDirs
}
func (d *Directory) UnmarshalJSON(data []byte) error {
var v struct {
baseFsNodeJSON
EnsureParentDirs bool `json:"ensure_parent_dirs"`
}
dec := json.NewDecoder(bytes.NewBuffer(data))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return err
}
d.baseFsNode.baseFsNodeJSON = v.baseFsNodeJSON
d.ensureParentDirs = v.EnsureParentDirs
return d.validate()
}
func (d *Directory) UnmarshalYAML(unmarshal func(any) error) error {
return common.UnmarshalYAMLviaJSON(d, unmarshal)
}
// NewDirectory creates a new directory with the given path, mode, user and group.
// user and group can be either a string (user name/group name), an int64 (UID/GID) or nil.
func NewDirectory(path string, mode *os.FileMode, user interface{}, group interface{}, ensureParentDirs bool) (*Directory, error) {

View file

@ -1,7 +1,11 @@
package fsnode
import (
"bytes"
"encoding/json"
"os"
"github.com/osbuild/images/internal/common"
)
type File struct {
@ -16,6 +20,27 @@ func (f *File) Data() []byte {
return f.data
}
func (f *File) UnmarshalJSON(data []byte) error {
var v struct {
baseFsNodeJSON
Data string `json:"data,omitempty"`
}
dec := json.NewDecoder(bytes.NewBuffer(data))
dec.DisallowUnknownFields()
if err := dec.Decode(&v); err != nil {
return err
}
f.baseFsNode.baseFsNodeJSON = v.baseFsNodeJSON
f.data = []byte(v.Data)
return f.validate()
}
func (f *File) UnmarshalYAML(unmarshal func(any) error) error {
return common.UnmarshalYAMLviaJSON(f, unmarshal)
}
// NewFile creates a new file with the given path, data, mode, user and group.
// user and group can be either a string (user name/group name), an int64 (UID/GID) or nil.
func NewFile(path string, mode *os.FileMode, user interface{}, group interface{}, data []byte) (*File, error) {

View file

@ -1,34 +1,42 @@
package fsnode
import (
"bytes"
"encoding/json"
"fmt"
"os"
"path"
"path/filepath"
"regexp"
"github.com/osbuild/images/internal/common"
)
const usernameRegex = `^[A-Za-z0-9_.][A-Za-z0-9_.-]{0,31}$`
const groupnameRegex = `^[A-Za-z0-9_][A-Za-z0-9_-]{0,31}$`
type baseFsNodeJSON struct {
Path string
Mode *os.FileMode
User interface{}
Group interface{}
}
type baseFsNode struct {
path string
mode *os.FileMode
user interface{}
group interface{}
baseFsNodeJSON
}
func (f *baseFsNode) Path() string {
if f == nil {
return ""
}
return f.path
return f.baseFsNodeJSON.Path
}
func (f *baseFsNode) Mode() *os.FileMode {
if f == nil {
return nil
}
return f.mode
return f.baseFsNodeJSON.Mode
}
// User can return either a string (user name) or an int64 (UID)
@ -36,7 +44,7 @@ func (f *baseFsNode) User() interface{} {
if f == nil {
return nil
}
return f.user
return f.baseFsNodeJSON.User
}
// Group can return either a string (group name) or an int64 (GID)
@ -44,15 +52,17 @@ func (f *baseFsNode) Group() interface{} {
if f == nil {
return nil
}
return f.group
return f.baseFsNodeJSON.Group
}
func newBaseFsNode(path string, mode *os.FileMode, user interface{}, group interface{}) (*baseFsNode, error) {
node := &baseFsNode{
path: path,
mode: mode,
user: user,
group: group,
baseFsNodeJSON: baseFsNodeJSON{
Path: path,
Mode: mode,
User: user,
Group: group,
},
}
err := node.validate()
@ -63,32 +73,43 @@ func newBaseFsNode(path string, mode *os.FileMode, user interface{}, group inter
}
func (f *baseFsNode) validate() error {
return f.baseFsNodeJSON.validate()
}
func (f *baseFsNodeJSON) validate() error {
// Check that the path is valid
if f.path == "" {
if f.Path == "" {
return fmt.Errorf("path must not be empty")
}
if f.path[0] != '/' {
if f.Path[0] != '/' {
return fmt.Errorf("path must be absolute")
}
if f.path[len(f.path)-1] == '/' {
if f.Path[len(f.Path)-1] == '/' {
return fmt.Errorf("path must not end with a slash")
}
if f.path != path.Clean(f.path) {
if f.Path != filepath.Clean(f.Path) {
return fmt.Errorf("path must be canonical")
}
// Check that the mode is valid
if f.mode != nil && *f.mode&os.ModeType != 0 {
if f.Mode != nil && *f.Mode&os.ModeType != 0 {
return fmt.Errorf("mode must not contain file type bits")
}
// Check that the user and group are valid
switch user := f.user.(type) {
switch user := f.User.(type) {
case string:
nameRegex := regexp.MustCompile(usernameRegex)
if !nameRegex.MatchString(user) {
return fmt.Errorf("user name %q doesn't conform to validating regex (%s)", user, nameRegex.String())
}
case float64:
if user != float64(int64(user)) {
return fmt.Errorf("user ID must be int")
}
if user < 0 {
return fmt.Errorf("user ID must be non-negative")
}
case int64:
if user < 0 {
return fmt.Errorf("user ID must be non-negative")
@ -99,12 +120,19 @@ func (f *baseFsNode) validate() error {
return fmt.Errorf("user must be either a string or an int64, got %T", user)
}
switch group := f.group.(type) {
switch group := f.Group.(type) {
case string:
nameRegex := regexp.MustCompile(groupnameRegex)
if !nameRegex.MatchString(group) {
return fmt.Errorf("group name %q doesn't conform to validating regex (%s)", group, nameRegex.String())
}
case float64:
if group != float64(int64(group)) {
return fmt.Errorf("group ID must be int")
}
if group < 0 {
return fmt.Errorf("group ID must be non-negative")
}
case int64:
if group < 0 {
return fmt.Errorf("group ID must be non-negative")
@ -117,3 +145,22 @@ func (f *baseFsNode) validate() error {
return nil
}
func (f *baseFsNode) UnmarshalJSON(data []byte) error {
var fv baseFsNodeJSON
dec := json.NewDecoder(bytes.NewBuffer(data))
if err := dec.Decode(&fv); err != nil {
return err
}
if err := fv.validate(); err != nil {
return err
}
f.baseFsNodeJSON = fv
return nil
}
func (f *baseFsNode) UnmarshalYAML(unmarshal func(any) error) error {
return common.UnmarshalYAMLviaJSON(f, unmarshal)
}