zrok/environment/env_v0_3/dirs.go
2023-07-13 14:26:35 -04:00

56 lines
985 B
Go

package env_v0_3
import (
"fmt"
"os"
"path/filepath"
)
func rootDir() (string, error) {
home, err := os.UserHomeDir()
if err != nil {
return "", err
}
return filepath.Join(home, ".zrok"), nil
}
func metadataFile() (string, error) {
zrd, err := rootDir()
if err != nil {
return "", err
}
return filepath.Join(zrd, "metadata.json"), nil
}
func configFile() (string, error) {
zrd, err := rootDir()
if err != nil {
return "", err
}
return filepath.Join(zrd, "config.json"), nil
}
func environmentFile() (string, error) {
zrd, err := rootDir()
if err != nil {
return "", err
}
return filepath.Join(zrd, "environment.json"), nil
}
func identitiesDir() (string, error) {
zrd, err := rootDir()
if err != nil {
return "", err
}
return filepath.Join(zrd, "identities"), nil
}
func identityFile(name string) (string, error) {
idd, err := identitiesDir()
if err != nil {
return "", err
}
return filepath.Join(idd, fmt.Sprintf("%v.json", name)), nil
}