mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
06d81cb936
* Replace ioutil package * check integration test null pointer * Remove rotate retries Signed-off-by: Derek Nola <derek.nola@suse.com>
31 lines
708 B
Go
31 lines
708 B
Go
package util
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func WriteFile(name string, content string) error {
|
|
os.MkdirAll(filepath.Dir(name), 0755)
|
|
err := os.WriteFile(name, []byte(content), 0644)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "writing %s", name)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func CopyFile(sourceFile string, destinationFile string) error {
|
|
os.MkdirAll(filepath.Dir(destinationFile), 0755)
|
|
input, err := os.ReadFile(sourceFile)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "copying %s to %s", sourceFile, destinationFile)
|
|
}
|
|
err = os.WriteFile(destinationFile, input, 0644)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "copying %s to %s", sourceFile, destinationFile)
|
|
}
|
|
return nil
|
|
}
|