From f333d95df7d91b14ccc52fa901904865959486b5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 19 Aug 2024 14:06:10 +0200 Subject: [PATCH] bib: update to images v0.78 and update for API changes Two changes: - The pathpolicy.PathTri type is no longer exported and it is `pathpolicy.Pathpolicies` instead - The error messages from images for path policy violations changes and need an update (arguable this is not the best layer to test the error details here and instead we should check how much we can move down to images but that is a followup :) --- bib/cmd/bootc-image-builder/image.go | 6 +++--- bib/cmd/bootc-image-builder/image_test.go | 10 +++++----- bib/go.mod | 12 ++++++------ bib/go.sum | 12 ++++++++++++ test/test_manifest.py | 2 +- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/bib/cmd/bootc-image-builder/image.go b/bib/cmd/bootc-image-builder/image.go index bd4fed661..2d59ea324 100644 --- a/bib/cmd/bootc-image-builder/image.go +++ b/bib/cmd/bootc-image-builder/image.go @@ -116,7 +116,7 @@ var ( }) ) -func checkMountpoints(filesystems []blueprint.FilesystemCustomization, policy *pathpolicy.PathTrie) error { +func checkMountpoints(filesystems []blueprint.FilesystemCustomization, policy *pathpolicy.PathPolicies) error { errs := []error{} for _, fs := range filesystems { if err := policy.Check(fs.Mountpoint); err != nil { @@ -125,7 +125,7 @@ func checkMountpoints(filesystems []blueprint.FilesystemCustomization, policy *p if fs.Mountpoint == "/var" { // this error message is consistent with the errors returned by policy.Check() // TODO: remove trailing space inside the quoted path when the function is fixed in osbuild/images. - errs = append(errs, fmt.Errorf("path '/var ' is not allowed")) + errs = append(errs, fmt.Errorf(`path "/var" is not allowed`)) } } if len(errs) > 0 { @@ -135,7 +135,7 @@ func checkMountpoints(filesystems []blueprint.FilesystemCustomization, policy *p } func checkFilesystemCustomizations(fsCustomizations []blueprint.FilesystemCustomization, ptmode disk.PartitioningMode) error { - var policy *pathpolicy.PathTrie + var policy *pathpolicy.PathPolicies switch ptmode { case disk.BtrfsPartitioningMode: // btrfs subvolumes are not supported at build time yet, so we only diff --git a/bib/cmd/bootc-image-builder/image_test.go b/bib/cmd/bootc-image-builder/image_test.go index c39729d32..68b327132 100644 --- a/bib/cmd/bootc-image-builder/image_test.go +++ b/bib/cmd/bootc-image-builder/image_test.go @@ -106,7 +106,7 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) { {Mountpoint: "/ostree"}, }, ptmode: disk.RawPartitioningMode, - expectedErr: "The following errors occurred while validating custom mountpoints:\npath '/ostree ' is not allowed", + expectedErr: "The following errors occurred while validating custom mountpoints:\npath \"/ostree\" is not allowed", }, { fsCust: []blueprint.FilesystemCustomization{ @@ -114,7 +114,7 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) { {Mountpoint: "/var"}, }, ptmode: disk.RawPartitioningMode, - expectedErr: "The following errors occurred while validating custom mountpoints:\npath '/var ' is not allowed", + expectedErr: "The following errors occurred while validating custom mountpoints:\npath \"/var\" is not allowed", }, { fsCust: []blueprint.FilesystemCustomization{ @@ -122,7 +122,7 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) { {Mountpoint: "/var/data"}, }, ptmode: disk.BtrfsPartitioningMode, - expectedErr: "The following errors occurred while validating custom mountpoints:\npath '/var/data ' is not allowed", + expectedErr: "The following errors occurred while validating custom mountpoints:\npath \"/var/data\" is not allowed", }, { fsCust: []blueprint.FilesystemCustomization{ @@ -130,7 +130,7 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) { {Mountpoint: "/boot/"}, }, ptmode: disk.BtrfsPartitioningMode, - expectedErr: "The following errors occurred while validating custom mountpoints:\npath must be canonical", + expectedErr: "The following errors occurred while validating custom mountpoints:\npath \"/boot/\" must be canonical", }, { fsCust: []blueprint.FilesystemCustomization{ @@ -139,7 +139,7 @@ func TestCheckFilesystemCustomizationsValidates(t *testing.T) { {Mountpoint: "/opt"}, }, ptmode: disk.BtrfsPartitioningMode, - expectedErr: "The following errors occurred while validating custom mountpoints:\npath must be canonical\npath '/opt ' is not allowed", + expectedErr: "The following errors occurred while validating custom mountpoints:\npath \"/boot/\" must be canonical\npath \"/opt\" is not allowed", }, } { if tc.expectedErr == "" { diff --git a/bib/go.mod b/bib/go.mod index b74e56a2c..95faf4ab7 100644 --- a/bib/go.mod +++ b/bib/go.mod @@ -9,12 +9,12 @@ require ( github.com/aws/aws-sdk-go v1.55.5 github.com/cheggaaa/pb/v3 v3.1.5 github.com/google/uuid v1.6.0 - github.com/osbuild/images v0.77.0 + github.com/osbuild/images v0.78.0 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 - golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/sys v0.24.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -29,8 +29,8 @@ require ( github.com/containerd/cgroups/v3 v3.0.3 // indirect github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect - github.com/containers/common v0.60.0 // indirect - github.com/containers/image/v5 v5.32.0 // indirect + github.com/containers/common v0.60.1 // indirect + github.com/containers/image/v5 v5.32.1 // indirect github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect github.com/containers/ocicrypt v1.2.0 // indirect github.com/containers/storage v1.55.0 // indirect @@ -78,7 +78,7 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mistifyio/go-zfs/v3 v3.0.1 // indirect @@ -109,7 +109,7 @@ require ( github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect github.com/ulikunitz/xz v0.5.12 // indirect github.com/vbatts/tar-split v0.11.5 // indirect - github.com/vbauerster/mpb/v8 v8.7.4 // indirect + github.com/vbauerster/mpb/v8 v8.7.5 // indirect go.mongodb.org/mongo-driver v1.14.0 // indirect go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect go.opencensus.io v0.24.0 // indirect diff --git a/bib/go.sum b/bib/go.sum index 15e96beb6..80b81b4e9 100644 --- a/bib/go.sum +++ b/bib/go.sum @@ -41,8 +41,12 @@ github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk= github.com/containers/common v0.60.0 h1:QMNygqiiit9LU/yqee9Dv0N0oQ+rQq41ElfdOBQtw7w= github.com/containers/common v0.60.0/go.mod h1:dtKVe11xkV89tqzRX9s/B0ORjeB2dy5UB46aGjunMn8= +github.com/containers/common v0.60.1 h1:hMJNKfDxfXY91zD7mr4t/Ybe8JbAsTq5nkrUaCqTKsA= +github.com/containers/common v0.60.1/go.mod h1:tB0DRxznmHviECVHnqgWbl+8AVCSMZLA8qe7+U7KD6k= github.com/containers/image/v5 v5.32.0 h1:yjbweazPfr8xOzQ2hkkYm1A2V0jN96/kES6Gwyxj7hQ= github.com/containers/image/v5 v5.32.0/go.mod h1:x5e0RDfGaY6bnQ13gJ2LqbfHvzssfB/y5a8HduGFxJc= +github.com/containers/image/v5 v5.32.1 h1:fVa7GxRC4BCPGsfSRs4JY12WyeY26SUYQ0NuANaCFrI= +github.com/containers/image/v5 v5.32.1/go.mod h1:v1l73VeMugfj/QtKI+jhYbwnwFCFnNGckvbST3rQ5Hk= github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA= github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY= github.com/containers/ocicrypt v1.2.0 h1:X14EgRK3xNFvJEfI5O4Qn4T3E25ANudSOZz/sirVuPM= @@ -192,6 +196,8 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU= @@ -227,6 +233,8 @@ github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaL github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec= github.com/osbuild/images v0.77.0 h1:O0Nv07M7b3YuY+c83/NFjWFachO+aH714zu7r+QkdsU= github.com/osbuild/images v0.77.0/go.mod h1:14LZWLSsQ02C/vZ+EzBkp+OcdjebnWDJ8moz8o/a0J4= +github.com/osbuild/images v0.78.0 h1:HyIgF2Jwwcy+WsUX2/+lO3OhKiAjN8RRbfRU1UnmMmw= +github.com/osbuild/images v0.78.0/go.mod h1:J3MpUYAoOp5wQGvqwm1lVcpQRJOAl5XQPqlAkkje8mk= github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f h1:/UDgs8FGMqwnHagNDPGOlts35QkhAZ8by3DR7nMih7M= github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f/go.mod h1:J6OG6YJVEWopen4avK3VNQSnALmmjvniMmni/YFYAwc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -295,6 +303,8 @@ github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinC github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk= github.com/vbauerster/mpb/v8 v8.7.4 h1:p4f16iMfUt3PkAC73SCzAtgtSf8TYDqEbJUT3odPrPo= github.com/vbauerster/mpb/v8 v8.7.4/go.mod h1:r1B5k2Ljj5KJFCekfihbiqyV4VaaRTANYmvWA2btufI= +github.com/vbauerster/mpb/v8 v8.7.5 h1:hUF3zaNsuaBBwzEFoCvfuX3cpesQXZC0Phm/JcHZQ+c= +github.com/vbauerster/mpb/v8 v8.7.5/go.mod h1:bRCnR7K+mj5WXKsy0NWB6Or+wctYGvVwKn6huwvxKa0= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= @@ -333,6 +343,8 @@ golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn5 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= diff --git a/test/test_manifest.py b/test/test_manifest.py index d38e237c9..b89a4b369 100644 --- a/test/test_manifest.py +++ b/test/test_manifest.py @@ -291,7 +291,7 @@ def test_mount_ostree_error(tmpdir_factory, build_container): "manifest", f"{container_ref}", "--config", "/output/config.json", ], stderr=subprocess.PIPE, encoding="utf8") - assert "The following errors occurred while validating custom mountpoints:\npath '/ostree ' is not allowed" \ + assert 'The following errors occurred while validating custom mountpoints:\npath "/ostree" is not allowed' \ in exc.value.stderr