2023-07-13 20:26:35 +02:00
|
|
|
package env_v0_3
|
2023-07-12 23:22:24 +02:00
|
|
|
|
|
|
|
import (
|
2023-07-13 20:26:35 +02:00
|
|
|
"fmt"
|
2023-07-12 23:22:24 +02:00
|
|
|
"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
|
|
|
|
}
|
2023-07-13 20:26:35 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|