Files
k3s/pkg/static/stage.go
Brad Davidson 3cb6c2dc92 Avoid use of github.com/pkg/errors functions that capture stack
We are not making use of the stack traces that these functions capture, so we should avoid using them as unnecessary overhead.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit bed1f66880)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-07 14:46:16 -08:00

29 lines
540 B
Go

//go:build !no_stage
package static
import (
"os"
"path/filepath"
pkgerrors "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
func Stage(dataDir string) error {
for _, name := range AssetNames() {
content, err := Asset(name)
if err != nil {
return err
}
p := filepath.Join(dataDir, name)
logrus.Info("Writing static file: ", p)
os.MkdirAll(filepath.Dir(p), 0700)
if err := os.WriteFile(p, content, 0600); err != nil {
return pkgerrors.WithMessagef(err, "failed to write to %s", name)
}
}
return nil
}