Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeCert(raw []byte) (*pem.Block, error)
- func DecodeKey(raw []byte) (*pem.Block, error)
- func EncodeCert(raw []byte) ([]byte, error)
- func EncodeKey(raw []byte) ([]byte, error)
- func EnsureProtectedFile(name string, relative string) error
- func InitLogger(rawLevel LogLevel, rawOutput LogOutput, rawFile string, relative string) (func(), error)
- func MakeDirs(name string, relative string, folderPerm os.FileMode) error
- func ParseLogLevel(rawLevel LogLevel) (slog.Level, error)
- func SafeCreate(name string, relative string, data []byte, filePerm os.FileMode, ...) error
- func SafeOpen(name string, relative string, filePerm os.FileMode, folderPerm os.FileMode, ...) (*os.File, error)
- func SafeRead(name string, relative string) ([]byte, error)
- type LogLevel
- type LogOutput
- type SafeOpenMode
Constants ¶
const ( // PROTECTED_FILE_MODE is the expected file mode for protected files PROTECTED_FILE_MODE = 0o600 // PROTECTED_FOLDER_MODE is the expected file mode for protected folders PROTECTED_FOLDER_MODE = 0o755 )
const CHALLENGE_ID_LENGTH = 32
CHALLENGE_ID_LENGTH is the length of the challenge ID (in bytes)
const CHALLENGE_STATE_LENGTH = 32
CHALLENGE_STATE_LENGTH is the length of the challenge OAuth state (in bytes)
const VERIFICATION_CODE_LENGTH = 6
VERIFICATION_CODE_LENGTH is the length of the code (in decimal digits)
Variables ¶
var About = fmt.Sprintf("%s (Build %s@%s at %s with %s)", Version, Commit, Branch, Timestamp.Format(time.RFC3339), runtime.Version())
About is the about string
var Branch = rawBranch
Branch is the branch the application was built from
var Commit = rawCommit
Commit is the commit the application was built from
var DEBUG = LogLevel(slog.LevelDebug.String())
LogLevel constants
var ERROR = LogLevel(slog.LevelError.String())
var INFO = LogLevel(slog.LevelInfo.String())
Timestamp is the time the application was built
var Version = lo.Must(version.NewSemver(rawVersion))
Version is the version of the application
var VersionConstraint = lo.Must(version.NewConstraint(fmt.Sprintf("~> %d.%d", Version.Segments()[0], Version.Segments()[1])))
VersionConstraint is the version constraint of the application
var WARN = LogLevel(slog.LevelWarn.String())
Functions ¶
func DecodeCert ¶
DecodeCert decodes a certificate from a PEM-encoded byte array
func EncodeCert ¶
EncodeCert encodes a certificate into a PEM-encoded byte array
func EnsureProtectedFile ¶
EnsureProtectedFile ensures that the file at the specified path is protected
func InitLogger ¶
func InitLogger(rawLevel LogLevel, rawOutput LogOutput, rawFile string, relative string) (func(), error)
InitLogger intializes a new slog logger, returning a cleanup function and an error (if any)
func ParseLogLevel ¶
ParseLogLevel parses a log level
func SafeCreate ¶
func SafeCreate(name string, relative string, data []byte, filePerm os.FileMode, folderPerm os.FileMode, mode SafeOpenMode) error
SafeCreate safely creates a new file with the specified data
Types ¶
type SafeOpenMode ¶
type SafeOpenMode int
SafeOpenMode is the mode to open a file
const ( // SAFE_OPEN_MODE_EXCL is the mode to create a new file, requiring that the file does not already exist SAFE_OPEN_MODE_EXCL SafeOpenMode = iota // SAFE_OPEN_MODE_APPEND is the mode to open a file for appending, creating the file if it does not exist SAFE_OPEN_MODE_APPEND // SAFE_OPEN_MODE_TRUNCATE is the mode to open a file for writing, creating the file if it does not exist and truncating it if it does SAFE_OPEN_MODE_TRUNCATE )