utilsk8s.io/utils/temp Index | Files | Directories

package temp

import "k8s.io/utils/temp"

Package temp provides an interface to handle temporary files and directories.

Index

Types

type Dir

type Dir struct {
	// Name is the name (full path) of the created directory.
	Name string
}

Dir is wrapping an temporary directory on disk.

func CreateTempDir

func CreateTempDir(prefix string) (*Dir, error)

CreateTempDir returns a new Directory wrapping a temporary directory on disk.

func (*Dir) Delete

func (d *Dir) Delete() error

Delete the underlying directory, and all of its content.

func (*Dir) NewFile

func (d *Dir) NewFile(name string) (io.WriteCloser, error)

NewFile creates a new file in the specified directory.

type Directory

type Directory interface {
	// NewFile creates a new file in that directory. Calling NewFile
	// with the same filename twice will result in an error.
	NewFile(name string) (io.WriteCloser, error)
	// Delete removes the directory and its content.
	Delete() error
}

Directory is an interface to a temporary directory, in which you can create new files.

Source Files

dir.go doc.go

Directories

PathSynopsis
temp/temptestPackage temptest provides utilities for testing temp files/directories testing.
Version
v0.0.0-20250321185631-1f6e0b77f77e (latest)
Published
Mar 21, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
1 month ago

Tools for package owners.