cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
cf5be91d2deeab445a2cc9631e8477ecc8447aaa

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmd/cloudflared/tunnel/filesystem.go

26lines · modecode

1package tunnel
2
3import (
4 "os"
5)
6
7// Abstract away details of reading files, so that SubcommandContext can read
8// from either the real filesystem, or a mock (when running unit tests).
9type fileSystem interface {
10 readFile(filePath string) ([]byte, error)
11 validFilePath(path string) bool
12}
13
14type realFileSystem struct{}
15
16func (fs realFileSystem) validFilePath(path string) bool {
17 fileStat, err := os.Stat(path)
18 if err != nil {
19 return false
20 }
21 return !fileStat.IsDir()
22}
23
24func (fs realFileSystem) readFile(filePath string) ([]byte, error) {
25 return os.ReadFile(filePath)
26}
27