Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyConfigDefaults(c *Config)
- func ApplySettingsDefaults(s *models.Settings)
- func Enabled(db *gorm.DB) bool
- func NewAPIHandler(repo *Repo) http.Handler
- func NewDeviceHTTP(repo *Repo) http.Handler
- func NormalizeProtocol(p string) (string, error)
- func PullCommands(platform, protocol, src, dest string) ([]string, error)
- func PullToDevice(req CopyRequest, src string) (string, error)
- func PushToDevice(repo *Repo, req CopyRequest) error
- func ServeSFTP(ln net.Listener, repo *Repo, user, pass string, hostKey ssh.Signer) error
- func ServeTFTP(ln net.PacketConn, repo *Repo) error
- func SourceURL(cfg *Config, protocol, relPath string) (string, error)
- func StorageSocketPath(yamlOverride string) string
- type Config
- type CopyRequest
- type Entry
- type Repo
- func (r *Repo) CreateFile(relPath string, offset int64) (*os.File, error)
- func (r *Repo) List(relPath string) ([]Entry, error)
- func (r *Repo) Mkdir(relPath string) error
- func (r *Repo) Move(from, to string) error
- func (r *Repo) Open(relPath string) (*os.File, Entry, error)
- func (r *Repo) Remove(relPath string) error
- func (r *Repo) Root() string
- func (r *Repo) Stat(relPath string) (Entry, error)
- func (r *Repo) WriteAt(relPath string, offset int64, data io.Reader) (int64, error)
- type Server
Constants ¶
const ( DefaultRoot = "/var/lib/factum2/storage" DefaultHTTPListen = ":8088" DefaultTFTPListen = ":69" DefaultSFTPListen = ":2222" DefaultSFTPUser = "factum" DefaultStorageSock = "/run/factum2-storage/api.sock" )
const MaxChunk = 8 << 20
MaxChunk is the largest PUT body the unix API accepts (hub frames stay under 32MiB).
Variables ¶
Functions ¶
func ApplyConfigDefaults ¶
func ApplyConfigDefaults(c *Config)
func ApplySettingsDefaults ¶
ApplySettingsDefaults fills empty storage paths when the feature is on.
func Enabled ¶
Enabled reports Settings.StorageEnabled (nil/false = off). Disabling the flag only hides the Software GUI and /api/software/* routes — it does not delete files on the storage host.
func NewAPIHandler ¶
func NewDeviceHTTP ¶
NewDeviceHTTP serves repository files for device pull (no auth).
func NormalizeProtocol ¶
func PullCommands ¶
PullCommands returns the CLI the device should run to copy src onto dest. src is a full locator (http://…, tftp://…). dest is the on-device path.
func PullToDevice ¶
func PullToDevice(req CopyRequest, src string) (string, error)
PullToDevice SSHes (via the platform driver) and runs the copy-from-URL command.
func PushToDevice ¶
func PushToDevice(repo *Repo, req CopyRequest) error
PushToDevice copies the local file to the device over SCP or SFTP.
func ServeTFTP ¶
func ServeTFTP(ln net.PacketConn, repo *Repo) error
ServeTFTP answers read-only RRQs from repo until ln is closed.
func StorageSocketPath ¶
StorageSocketPath resolves the daemon unix API path. yamlOverride is ConfigStorage.Socket. "none"/"0" disables the socket. Empty uses DefaultStorageSock.
Types ¶
type Config ¶
type Config struct {
util.CommonConfig
Root string `json:"root"`
HTTPListen string `json:"http_listen"`
HTTPURL string `json:"http_url"`
TFTPListen string `json:"tftp_listen"`
TFTPHost string `json:"tftp_host"`
SFTPListen string `json:"sftp_listen"`
SFTPHost string `json:"sftp_host"`
SFTPUser string `json:"sftp_user"`
SFTPPassword string `json:"sftp_password"`
}
Config is what factum2-storage fetches from the primary (GET /api/storage-config). Paths and listen addresses apply on the storage host, which may be the primary or a remote worker.
func FetchRemoteConfig ¶
func FetchRemoteConfig(factumConfig *util.ConfigFactum) (*Config, error)
type CopyRequest ¶
type CopyRequest struct {
Path string `json:"path"`
Device string `json:"device"`
Protocol string `json:"protocol"` // http, tftp, scp, sftp
Destination string `json:"destination"`
Username string `json:"-"`
Password string `json:"-"`
Platform string `json:"-"`
Host string `json:"-"` // device FQDN/IP to dial for push
}
CopyRequest is a factum→device transfer of one repository file.
type Entry ¶
type Entry struct {
Name string `json:"name"`
Path string `json:"path"`
IsDir bool `json:"is_dir"`
HasChildren bool `json:"has_children"`
Size int64 `json:"size"`
ModTime time.Time `json:"mod_time"`
}
Entry is one file or folder in the software repository.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is a path-jailed directory tree used as the software image store.
func (*Repo) CreateFile ¶
CreateFile opens path for writing. offset 0 truncates (or creates). A non-zero offset writes at that position (chunked upload).