dotrill

package
v0.51.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dotrill implements setting and getting key-value pairs in YAML files in ~/.rill.

Index

Constants

View Source
const (
	ConfigFilename      = "config.yaml"      // For user-facing config
	CredentialsFilename = "credentials.yaml" // For access tokens
	StateFilename       = "state.yaml"       // For CLI state
)

Constants for YAML files

View Source
const (
	DefaultOrgConfigKey            = "org"
	DefaultAdminURLConfigKey       = "api_url"
	AnalyticsEnabledConfigKey      = "analytics_enabled"
	AccessTokenCredentialsKey      = "token"
	InstallIDStateKey              = "install_id"
	RepresentingUserCredentialsKey = "representing_user"
	BackupTokenCredentialsKey      = "backup_token"
	LatestVersionStateKey          = "latest_version"
	LatestVersionCheckedAtStateKey = "latest_version_checked_at"
	UserIDStateKey                 = "user_id"
	UserCheckHashStateKey          = "user_check_hash"
)

Constants for YAML keys

Variables

This section is empty.

Functions

func AnalyticsInfo

func AnalyticsInfo() (installID string, enabled bool, err error)

AnalyticsInfo returns analytics info. It loads a persistent install ID from ~/.rill/state.yaml (setting one if not found). It gets analytics enabled/disabled info from ~/.rill/config.yaml (key "analytics_enabled"). It automatically migrates from the pre-v0.23 analytics config. See migrateOldAnalyticsConfig for details.

func Get

func Get(filename, key string) (string, error)

Get returns a single entry from ~/.rill/{filename}. It assumes filename identifies a YAML file.

func GetAccessToken

func GetAccessToken() (string, error)

GetToken loads the current auth token

func GetAll

func GetAll(filename string) (map[string]string, error)

GetAll loads all values from ~/.rill/{filename}. It assumes filename identifies a YAML file.

func GetBackupToken added in v0.27.0

func GetBackupToken() (string, error)

GetBackupToken loads the original auth token

func GetDefaultAdminURL added in v0.24.0

func GetDefaultAdminURL() (string, error)

GetDefaultAdminURL loads the default admin URL (if set)

func GetDefaultOrg

func GetDefaultOrg() (string, error)

GetDefaultOrg loads the default org

func GetEnvToken added in v0.28.2

func GetEnvToken(env string) (string, error)

GetEnvToken loads the token for given env

func GetRepresentingUser added in v0.27.0

func GetRepresentingUser() (string, error)

GetRepresentingUser loads the current representing user email

func GetUserCheckHash added in v0.42.0

func GetUserCheckHash() (string, error)

GetUserCheckHash gets the hash used to determine whether to re-fetch the user ID.

func GetUserID added in v0.42.0

func GetUserID() (string, error)

GetCurrentUserID gets the current user ID

func GetVersion added in v0.24.1

func GetVersion() (string, error)

func GetVersionUpdatedAt added in v0.24.1

func GetVersionUpdatedAt() (string, error)

func ResolveFilename added in v0.26.0

func ResolveFilename(name string, mkdir bool) (string, error)

ResolveFilename resolves a file name to a full path to ~/.rill. If mkdir is true, it will create the .rill directory if it doesn't exist.

func Set

func Set(filename, key, value string) error

Set sets a single value in ~/.rill/{filename}. It assumes filename identifies a YAML file.

func SetAccessToken

func SetAccessToken(token string) error

SetToken saves an auth token

func SetBackupToken added in v0.27.0

func SetBackupToken(token string) error

SetBackupToken saves original auth token

func SetDefaultAdminURL added in v0.26.0

func SetDefaultAdminURL(url string) error

SetDefaultAdminURL loads the default admin URL (if set)

func SetDefaultOrg

func SetDefaultOrg(orgName string) error

SetDefaultOrg saves the default org

func SetEnvToken added in v0.28.2

func SetEnvToken(env, token string) error

SetEnvToken backup the token for given env

func SetRepresentingUser added in v0.27.0

func SetRepresentingUser(email string) error

SetRepresentingUser saves representing user email

func SetUserCheckHash added in v0.42.0

func SetUserCheckHash(hash string) error

SetUserCheckHash sets the hash used to determine whether to re-fetch the user ID.

func SetUserID added in v0.42.0

func SetUserID(userID string) error

SetCurrentUserID saves the current user ID

func SetVersion added in v0.24.1

func SetVersion(version string) error

func SetVersionUpdatedAt added in v0.24.1

func SetVersionUpdatedAt(updatedAt string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL