talos/internal/pkg/extensions/extensions_test.go
Andrey Smirnov 9be7bc0250
fix: don't set xattrs while decompressing extensions
When decompressing extensions, we might not be able to set xattrs (e.g.
running rootless), so instead of setting xattrs, save them in memory and
push to mksquashfs as pseudo definitions.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
(cherry picked from commit d697f5538a7a624a1ac7bafdfebc67dd9418c434)
2026-04-15 18:38:38 +04:00

39 lines
1.1 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package extensions_test
import (
"os/exec"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/siderolabs/talos/internal/pkg/extensions"
"github.com/siderolabs/talos/pkg/machinery/imager/quirks"
)
func TestCompress(t *testing.T) {
// Compress is going to change contents of the extension, copy to some temporary directory
extDir := t.TempDir()
require.NoError(t, exec.CommandContext(t.Context(), "cp", "-r", "testdata/good/extension1", extDir).Run())
exts, err := extensions.List(extDir)
require.NoError(t, err)
require.Len(t, exts, 1)
ext := exts[0]
squashDest, initramfsDest := t.TempDir(), t.TempDir()
squashFile, err := ext.Compress(t.Context(), squashDest, initramfsDest, quirks.New(""), nil)
assert.NoError(t, err)
assert.FileExists(t, squashFile)
assert.FileExists(t, filepath.Join(initramfsDest, "usr", "lib", "firmware", "amd", "cpu"))
}