dotrill

package
v0.64.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License: Apache-2.0 Imports: 8 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"
	BackupDefaultOrgConfigKey                       = "backup_org"
	DefaultAdminURLConfigKey                        = "api_url"
	AnalyticsEnabledConfigKey                       = "analytics_enabled"
	AccessTokenCredentialsKey                       = "token"
	InstallIDStateKey                               = "install_id"
	RepresentingUserCredentialsKey                  = "representing_user"
	RepresentingUserAccessTokenExpiryCredentialsKey = "representing_user_token_expiry"
	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

This section is empty.

Types

type DotRill added in v0.60.7

type DotRill struct {
	// contains filtered or unexported fields
}

DotRill encapsulates access to .rill.

func New added in v0.60.7

func New(homeDir string) DotRill

New creates a new Dotrill instance. If homeDir is empty, it creates `.rill` in the user's home directory.

func (DotRill) AnalyticsInfo added in v0.60.7

func (d DotRill) 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 (DotRill) Get added in v0.60.7

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

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

func (DotRill) GetAccessToken added in v0.60.7

func (d DotRill) GetAccessToken() (string, error)

GetToken loads the current auth token

func (DotRill) GetAll added in v0.60.7

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

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

func (DotRill) GetBackupDefaultOrg added in v0.61.0

func (d DotRill) GetBackupDefaultOrg() (string, error)

GetBackupDefaultOrg loads the backedup default org

func (DotRill) GetBackupToken added in v0.60.7

func (d DotRill) GetBackupToken() (string, error)

GetBackupToken loads the original auth token

func (DotRill) GetDefaultAdminURL added in v0.60.7

func (d DotRill) GetDefaultAdminURL() (string, error)

GetDefaultAdminURL loads the default admin URL (if set)

func (DotRill) GetDefaultOrg added in v0.60.7

func (d DotRill) GetDefaultOrg() (string, error)

GetDefaultOrg loads the default org

func (DotRill) GetEnvToken added in v0.60.7

func (d DotRill) GetEnvToken(env string) (string, error)

GetEnvToken loads the token for given env

func (DotRill) GetRepresentingUser added in v0.60.7

func (d DotRill) GetRepresentingUser() (string, error)

GetRepresentingUser loads the current representing user email

func (DotRill) GetRepresentingUserAccessTokenExpiry added in v0.61.0

func (d DotRill) GetRepresentingUserAccessTokenExpiry() (time.Time, error)

GetRepresentingUserAccessTokenExpiry loads the current auth token expiry

func (DotRill) GetUserCheckHash added in v0.60.7

func (d DotRill) GetUserCheckHash() (string, error)

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

func (DotRill) GetUserID added in v0.60.7

func (d DotRill) GetUserID() (string, error)

GetCurrentUserID gets the current user ID

func (DotRill) GetVersion added in v0.60.7

func (d DotRill) GetVersion() (string, error)

func (DotRill) GetVersionUpdatedAt added in v0.60.7

func (d DotRill) GetVersionUpdatedAt() (string, error)

func (DotRill) ResolveFilename added in v0.60.7

func (d DotRill) 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 (DotRill) Set added in v0.60.7

func (d DotRill) Set(filename, key, value string) error

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

func (DotRill) SetAccessToken added in v0.60.7

func (d DotRill) SetAccessToken(token string) error

SetToken saves an auth token

func (DotRill) SetBackupDefaultOrg added in v0.61.0

func (d DotRill) SetBackupDefaultOrg(orgName string) error

SetBackupDefaultOrg saves the backedup default org

func (DotRill) SetBackupToken added in v0.60.7

func (d DotRill) SetBackupToken(token string) error

SetBackupToken saves original auth token

func (DotRill) SetDefaultAdminURL added in v0.60.7

func (d DotRill) SetDefaultAdminURL(url string) error

SetDefaultAdminURL loads the default admin URL (if set)

func (DotRill) SetDefaultOrg added in v0.60.7

func (d DotRill) SetDefaultOrg(orgName string) error

SetDefaultOrg saves the default org

func (DotRill) SetEnvToken added in v0.60.7

func (d DotRill) SetEnvToken(env, token string) error

SetEnvToken backup the token for given env

func (DotRill) SetRepresentingUser added in v0.60.7

func (d DotRill) SetRepresentingUser(email string) error

SetRepresentingUser saves representing user email

func (DotRill) SetRepresentingUserAccessTokenExpiry added in v0.61.0

func (d DotRill) SetRepresentingUserAccessTokenExpiry(expiry time.Time) error

SetRepresentingUserAccessTokenExpiry saves an auth token expiry

func (DotRill) SetUserCheckHash added in v0.60.7

func (d DotRill) SetUserCheckHash(hash string) error

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

func (DotRill) SetUserID added in v0.60.7

func (d DotRill) SetUserID(userID string) error

SetCurrentUserID saves the current user ID

func (DotRill) SetVersion added in v0.60.7

func (d DotRill) SetVersion(version string) error

func (DotRill) SetVersionUpdatedAt added in v0.60.7

func (d DotRill) SetVersionUpdatedAt(updatedAt string) error

Jump to

Keyboard shortcuts

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