talos
56 строк · 1.4 Кб
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5// Package extensions contains Talos extensions specific API.
6package extensions7
8import "path/filepath"9
10// AllowedPaths lists paths allowed in the extension images.
11var AllowedPaths = []string{12"/etc/cri/conf.d",13"/lib/firmware",14"/lib/modules",15"/lib64/ld-linux-x86-64.so.2",16"/usr/etc/udev/rules.d",17"/usr/local",18// glvnd, egl and vulkan are needed for OpenGL/Vulkan.19"/usr/share/glvnd",20"/usr/share/egl",21"/etc/vulkan",22}
23
24// Extension represents unpacked extension in the filesystem.
25type Extension struct {26Manifest Manifest
27
28directory string29rootfsPath string30}
31
32// RootfsPath returns the path to the rootfs directory.
33func (ext *Extension) RootfsPath() string {34return ext.rootfsPath35}
36
37// Directory returns the directory name of the extension.
38func (ext *Extension) Directory() string {39return ext.directory40}
41
42// New creates a new extension from the rootfs path, directory name and manifest.
43func New(rootfsPath, directory string, manifest Manifest) *Extension {44extension := &Extension{45Manifest: manifest,46
47rootfsPath: rootfsPath,48directory: directory,49}50
51if extension.directory == "" {52extension.directory = filepath.Base(rootfsPath)53}54
55return extension56}
57