### Basic Setup Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md A three-step guide for basic Doppler CLI setup. ```bash # 1. Authenticate doppler login # 2. Select project and config doppler setup # 3. Verify doppler configure --all ``` -------------------------------- ### Configuration Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Example demonstrating how to get the configuration directory and environment variables, and require a value. ```go import "github.com/DopplerHQ/cli/pkg/utils" configDir := utils.GetConfigHome() token := utils.GetEnv("DOPPLER_TOKEN", "") if token == "" { utils.RequireValue("DOPPLER_TOKEN", token) } ``` -------------------------------- ### Setup Examples Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Examples of how to set up Doppler CLI for a project and configuration. ```bash doppler setup doppler setup --project my-project --config prod ``` -------------------------------- ### Multiple Projects Setup Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Instructions for setting up multiple projects with Doppler CLI. ```bash # Setup root token doppler login --scope=/ # Setup project A cd ~/projects/project-a doppler setup --scope=./ # Setup project B cd ~/projects/project-b doppler setup --scope=./ ``` -------------------------------- ### Interactive Setup Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Shows how to perform an interactive setup for project and configuration. ```bash # Interactive setup (defaults to current directory scope) doppler setup # Setup with specific scope doppler setup --scope=./ doppler setup --scope=~/projects/backend ``` -------------------------------- ### Logging Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Example demonstrating how to use logging utilities like LogInfo, LogDebug, and LogWarning. ```go import "github.com/DopplerHQ/cli/pkg/utils" utils.LogInfo("Operation started") utils.LogDebug("Detailed debugging info") utils.LogWarning("This might be a problem") ``` -------------------------------- ### File Operations Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Example illustrating how to read and write files using GetFile and WriteFile utilities. ```go import "github.com/DopplerHQ/cli/pkg/utils" content, err := utils.GetFile("/path/to/file") if err != nil { utils.HandleError(err, "Cannot read file") } err = utils.WriteFile("/path/to/file", []byte(content), 0o600) ``` -------------------------------- ### Install Doppler CLI with Git Bash on Windows Source: https://github.com/dopplerhq/cli/blob/master/INSTALL.md Install the Doppler CLI using a shell script via Git Bash on Windows. This method installs the binary to `$HOME/bin`. ```sh $ mkdir -p $HOME/bin $ curl -Ls --tlsv1.2 --proto "=https" --retry 3 https://cli.doppler.com/install.sh | sh -s -- --install-path $HOME/bin $ doppler --version ``` -------------------------------- ### Quick Start (For Library Usage) Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/README.md Example of how to use Doppler CLI functionality programmatically in Go, including making an HTTP API call to get secrets, parsing the response, and using the secrets. ```go import ( "github.com/DopplerHQ/cli/pkg/http" "github.com/DopplerHQ/cli/pkg/controllers" "github.com/DopplerHQ/cli/pkg/models" ) // 1. Make HTTP API call secrets, err := http.GetSecrets( "https://api.doppler.com", true, // verify TLS token, projectID, configID, nil, // all secrets false, // no dynamic secrets 0, // no TTL ) // 2. Parse response parsed, _ := models.ParseSecrets(secrets) // 3. Use secrets for name, secret := range parsed { fmt.Printf("%s=%s\n", name, *secret.ComputedValue) } ``` -------------------------------- ### Scoped Configuration Examples Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Examples of how to set configuration scopes using the Doppler CLI. ```bash # Set global token (applies to all directories) doppler configure --token --scope=/ # Set project for current directory doppler setup --scope=./ # Set project for specific directory doppler configure --project my-project --scope=~/projects/backend ``` -------------------------------- ### Login Examples Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Examples of how to log in to Doppler CLI, including global and project-specific tokens. ```bash # Global token doppler login # Project-specific token doppler login --scope=~/projects/backend ``` -------------------------------- ### Configure Examples Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Examples of how to view and modify Doppler CLI configuration settings. ```bash # View all config doppler configure --all # View specific value doppler configure --config token # Set value doppler configure --token doppler configure --project my-project # Set flags doppler configure --flags analytics=false update-check=false ``` -------------------------------- ### RunInstallScript Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Execute CLI installation script. ```go func RunInstallScript() (bool, string, Error) ``` -------------------------------- ### Install and update Doppler CLI on Windows Source: https://github.com/dopplerhq/cli/blob/master/README.md Use winget to install or upgrade the Doppler CLI on Windows. ```sh $ winget install doppler $ doppler --version ``` ```sh $ winget upgrade doppler ``` -------------------------------- ### SetSecrets Example Usage Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Example of how to use the SetSecrets function with a list of changes. ```go changes := []models.ChangeRequest{ {Name: "API_KEY", Value: "new_value"}, {Name: "OLD_KEY", ShouldDelete: ptrBool(true)}, } secrets, err := controllers.SetSecrets(config, changes) ``` -------------------------------- ### Error Handling Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Example showing how to handle errors using the HandleError utility function. ```go import "github.com/DopplerHQ/cli/pkg/utils" if err != nil { utils.HandleError(err, "Failed to fetch secrets") } ``` -------------------------------- ### List Projects Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Examples for listing all projects. ```bash doppler projects list ``` ```bash doppler projects list --json ``` -------------------------------- ### Create Project Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for creating a new project. ```bash doppler projects create my-app --description "Main production app" ``` -------------------------------- ### Install Doppler CLI with Scoop on Windows Source: https://github.com/dopplerhq/cli/blob/master/INSTALL.md Use Scoop to install the Doppler CLI on Windows. This involves adding the Doppler repository first. To update, run `scoop update doppler`. ```sh $ scoop bucket add doppler https://github.com/DopplerHQ/scoop-doppler.git $ scoop install doppler $ doppler --version ``` ```sh $ scoop update doppler ``` -------------------------------- ### Install Doppler CLI via shell script Source: https://github.com/dopplerhq/cli/blob/master/README.md Use a shell script for installation in CI environments or where package managers are not used. ```sh $ (curl -Ls --tlsv1.2 --proto "=https" --retry 3 https://cli.doppler.com/install.sh || wget -t 3 -qO- https://cli.doppler.com/install.sh) | sh ``` -------------------------------- ### Create Config Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for creating a new config. ```bash doppler configs create staging --project my-project --environment staging ``` -------------------------------- ### GetSecrets Example Usage Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Example of how to use the GetSecrets function and process the returned secrets. ```go secrets, err := controllers.GetSecrets(config) if !err.IsNil() { log.Fatal(err.Message) } for name, secret := range secrets { fmt.Printf("%s: %s\n", name, *secret.ComputedValue) } ``` -------------------------------- ### List Configs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for listing configs in an environment. ```bash doppler configs list --project my-project --environment prod ``` -------------------------------- ### Install Doppler CLI with apt on Debian/Ubuntu Source: https://github.com/dopplerhq/cli/blob/master/INSTALL.md Install the Doppler CLI on Debian/Ubuntu systems using apt. This requires updating package lists and installing prerequisites. To update, run `sudo apt-get update && sudo apt-get upgrade doppler`. ```sh # install pre-reqs $ apt-get update && apt-get install -y apt-transport-https ca-certificates curl gnupg sudo # add Doppler's GPG key $ curl -sLf --retry 3 --tlsv1.2 --proto "=https" 'https://packages.doppler.com/public/cli/gpg.DE2A7741A397C129.key' | gpg --dearmor | sudo tee /etc/apt/keyrings/doppler.gpg >/dev/null # add Doppler's apt repo $ echo "deb [signed-by=/etc/apt/keyrings/doppler.gpg] https://packages.doppler.com/public/cli/deb/debian any-version main" | sudo tee /etc/apt/sources.list.d/doppler-cli.list # fetch and install latest doppler cli $ sudo apt-get update && sudo apt-get install doppler # (optional) print cli version $ doppler --version ``` ```sh $ sudo apt-get update && sudo apt-get upgrade doppler ``` -------------------------------- ### List Environments Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for listing environments in a project. ```bash doppler environments list --project my-project ``` -------------------------------- ### Create Environment Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for creating a new environment. ```bash doppler environments create staging --project my-project --slug staging ``` -------------------------------- ### Retries Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Example demonstrating the use of the Retry utility function for handling operations that may require multiple attempts. ```go import "github.com/DopplerHQ/cli/pkg/utils" import "time" err := utils.Retry(3, 100*time.Millisecond, func() error { return fetchSecretsFromAPI() }) ``` -------------------------------- ### Logout Examples Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Examples of how to log out from Doppler CLI, including logging out from all scopes. ```bash doppler logout doppler logout --all ``` -------------------------------- ### PromptToUpdate Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Prompt user to install a CLI update. ```go func PromptToUpdate(latestVersion models.VersionCheck) ``` -------------------------------- ### Configuration Functions Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Go code examples for interacting with the configuration system. ```go configuration.Setup() configuration.LoadConfig() ``` ```go analyticsEnabled := configuration.GetFlag(models.FlagAnalytics) ``` ```go config := configuration.LocalConfig(cmd) ``` ```go normalized, err := configuration.NormalizeScope("/path/to/dir") ``` ```go configuration.SetConfigDir("/custom/config/path") ``` -------------------------------- ### View Activity Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Examples for viewing workplace activity logs. ```bash doppler activity ``` ```bash doppler activity --json ``` -------------------------------- ### InstallUpdate Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Attempt to install a CLI update. ```go func InstallUpdate(version string) ``` -------------------------------- ### Build the Doppler CLI Source: https://github.com/dopplerhq/cli/blob/master/BUILD.md Compiles the CLI from source and verifies the installation. ```sh $ make build $ ./doppler --version ``` -------------------------------- ### Install and update Doppler CLI on macOS Source: https://github.com/dopplerhq/cli/blob/master/README.md Use Homebrew to install or upgrade the Doppler CLI on macOS. ```sh $ brew install dopplerhq/cli/doppler $ doppler --version ``` ```sh $ brew upgrade doppler ``` -------------------------------- ### GetConfigNames Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Get list of config names. ```go func GetConfigNames(config models.ScopedOptions) ([]string, Error) ``` -------------------------------- ### Custom DNS Resolution Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Examples of using a custom DNS resolver. ```bash doppler --enable-dns-resolver --dns-resolver-address 8.8.8.8:53 secrets get API_KEY DOPPLER_ENABLE_DNS_RESOLVER=true doppler secrets get API_KEY ``` -------------------------------- ### Install Doppler CLI with yum on RedHat/CentOS Source: https://github.com/dopplerhq/cli/blob/master/INSTALL.md Install the Doppler CLI on RedHat/CentOS systems using yum. This involves importing the GPG key and adding the yum repository. To update, run `sudo yum update doppler`. ```sh # add Doppler's GPG key $ sudo rpm --import 'https://packages.doppler.com/public/cli/gpg.DE2A7741A397C129.key' # add Doppler's yum repo $ curl -sLf --retry 3 --tlsv1.2 --proto "=https" 'https://packages.doppler.com/public/cli/config.rpm.txt' | sudo tee /etc/yum.repos.d/doppler-cli.repo # update packages and install latest doppler cli $ sudo yum update && sudo yum install doppler # (optional) print cli version $ doppler --version ``` ```sh $ sudo yum update doppler ``` -------------------------------- ### Encryption Error Handling Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example demonstrating decryption with a wrong passphrase, which would trigger an encryption error. ```go // Decryption of fallback file with wrong passphrase data, err := controllers.SecretsCacheFileBytes(path, wrongPassphrase) // Will return error if passphrase is incorrect ``` -------------------------------- ### Unlock Config Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for unlocking a config. ```bash doppler configs unlock --project my-project --config prod ``` -------------------------------- ### Install Doppler CLI with apk on Alpine Linux Source: https://github.com/dopplerhq/cli/blob/master/INSTALL.md Install the Doppler CLI on Alpine Linux using apk. This involves adding the Doppler GPG key and repository first. To update, run `apk upgrade doppler`. ```sh # add Doppler's RSA key $ wget -q -t3 'https://packages.doppler.com/public/cli/rsa.8004D9FF50437357.key' -O /etc/apk/keys/cli@doppler-8004D9FF50437357.rsa.pub # add Doppler's apk repo $ echo 'https://packages.doppler.com/public/cli/alpine/any-version/main' | tee -a /etc/apk/repositories # fetch and install latest doppler cli $ apk add doppler # (optional) print cli version $ doppler --version ``` ```sh $ apk upgrade doppler ``` -------------------------------- ### Configuration Precedence Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Illustrates how Doppler CLI resolves configuration values based on precedence. ```bash # If set via flag doppler --token abc123 secrets get API_KEY # Falls back to env var DOPPLER_TOKEN=abc123 doppler secrets get API_KEY # Falls back to scoped config doppler setup # Sets in ~/.config/doppler/config.yaml doppler secrets get API_KEY # Uses default if all above are missing doppler secrets get API_KEY # Error: token required ``` -------------------------------- ### Retry with Backoff Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Examples of increasing retry attempts and timeout for transient network failures. ```bash # Increase retry attempts doppler --attempts 10 secrets download # Increase timeout for slow networks doppler --timeout 120s secrets download ``` -------------------------------- ### GetConfigs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Get list of configs for current project. ```go func GetConfigs(config models.ScopedOptions) ([]models.ConfigInfo, Error) ``` -------------------------------- ### GetProject Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Get a specific project. ```go func GetProject(host string, verifyTLS bool, apiKey string, project string) (models.ProjectInfo, Error) ``` -------------------------------- ### Delete Project Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for deleting a project. ```bash doppler projects delete proj_XXX ``` -------------------------------- ### Install Doppler CLI via Shell Script Source: https://github.com/dopplerhq/cli/blob/master/INSTALL.md Install the latest Doppler CLI version using a shell script. This method is recommended for ephemeral environments like CI jobs. The script automatically detects the system architecture. ```sh (curl -Ls --tlsv1.2 --proto "=https" --retry 3 https://cli.doppler.com/install.sh || wget -t 3 -qO- https://cli.doppler.com/install.sh) | sh ``` -------------------------------- ### Basic Usage Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Examples of basic doppler run commands. ```bash doppler run -- node server.js ``` ```bash doppler run --fallback -- python app.py ``` ```bash doppler run --mount=/tmp/secrets.json -- myapp ``` ```bash doppler run --mount-template='{"api":"{{API_KEY}}"}' -- app ``` -------------------------------- ### GetEnvironment Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Get a specific environment. ```go func GetEnvironment(host string, verifyTLS bool, apiKey string, project string, environment string) (models.EnvironmentInfo, Error) ``` -------------------------------- ### GetWorkplaceSettings Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Get workplace settings. ```go func GetWorkplaceSettings(host string, verifyTLS bool, apiKey string) (models.WorkplaceSettings, Error) ``` -------------------------------- ### Lock Config Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example for locking a config. ```bash doppler configs lock --project my-project --config prod ``` -------------------------------- ### GetConfig Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Get a specific config. ```go func GetConfig(host string, verifyTLS bool, apiKey string, project string, config string) (models.ConfigInfo, Error) ``` -------------------------------- ### Configuration Error Handling Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of handling errors during configuration loading or validation. ```go normalized, err := configuration.NormalizeScope(scope) if err != nil { log.Fatalf("Invalid scope: %v", err) } ``` -------------------------------- ### GetProjectIDs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Get list of project IDs. ```go func GetProjectIDs(config models.ScopedOptions) ([]string, Error) ``` -------------------------------- ### Get specific config log response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example response structure for getting a specific config log. ```json { "log": { "id": "log_XXX", ... } } ``` -------------------------------- ### GetConfigTokenSlugs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Get list of service token slugs. ```go func GetConfigTokenSlugs(config models.ScopedOptions) ([]string, Error) ``` -------------------------------- ### Offline Mode Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Shows how to download secrets to cache and then read them later in offline mode. ```bash # Download and cache secrets doppler secrets download --format=json > .env.json # Later, read from cache (without network) source <(doppler secrets download --format=env-file --cache) ``` -------------------------------- ### Get specific activity log response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example response structure for getting a specific activity log. ```json { "activity": { "id": "act_XXX", "text": "...", ... } } ``` -------------------------------- ### ContainsPrefix Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Check if string starts with any prefix in slice. ```go func ContainsPrefix(s string, prefixes []string) bool ``` -------------------------------- ### Get Workplace Settings Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example JSON response when retrieving workplace settings. ```json { "workplace": { "id": "wp_XXX", "name": "My Workplace", "billing_email": "billing@example.com" } } ``` -------------------------------- ### GetPathFlag Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Get file path CLI flag. ```go func GetPathFlag(cmd *cobra.Command, flag string) string ``` -------------------------------- ### Configuration File Structure Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Example structure of the Doppler CLI configuration file in YAML format. ```yaml scoped: /path/to/directory: token: api-host: https://api.doppler.com dashboard-host: https://dashboard.doppler.com verify-tls: "true" enclave.project: enclave.config: version-check: latest-version: "3.25.0" checked-at: 2024-01-15T10:30:00Z analytics: disable: false tui: introVersionSeen: 1 flags: analytics: true update-check: true env-warning: true ``` -------------------------------- ### CI/CD Integration Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Examples of integrating Doppler into CI/CD pipelines using environment variables or CLI flags. ```bash # Using environment variables export DOPPLER_TOKEN=dp.pt_... export DOPPLER_PROJECT=my-project export DOPPLER_CONFIG=prod doppler secrets download --format=json > secrets.json # Using CLI flags doppler --token dp.pt_... secrets get API_KEY --project my-project --config prod ``` -------------------------------- ### Set Feature Flags Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Examples of setting feature flags using the `doppler configure --flags` command. ```bash doppler configure --flags analytics=false doppler configure --flags update-check=false ``` -------------------------------- ### GET /v3/environments/environment - Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Response for getting a specific environment. ```json { "environment": { "id": "env_XXX", "name": "Production", "created_at": "2024-01-15T10:30:00Z", "initial_fetch_at": "2024-01-16T10:30:00Z", "project": "proj_XXX" } } ``` -------------------------------- ### Handling Not Found Errors Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of how to handle a 404 Not Found error, indicating that a requested resource does not exist. ```Go _, err := http.GetProject(...) if err.Code == 404 { log.Fatal("Project not found") } ``` -------------------------------- ### Fallback to Cache Example Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Demonstrates how to use the `--fallback` flag to use cached secrets when the API is unreachable. ```bash doppler run --fallback -- myapp ``` -------------------------------- ### GET /v3/projects/project - Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Response for getting a specific project. ```json { "project": { "id": "proj_XXX", "name": "My Project", "description": "Description", "created_at": "2024-01-15T10:30:00Z" } } ``` -------------------------------- ### CI/CD Environment Mode Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example of setting environment variables for CI/CD pipelines and downloading secrets. ```bash export DOPPLER_TOKEN=dp.pt_... export DOPPLER_PROJECT=my-project export DOPPLER_CONFIG=prod doppler secrets download --format=json > ./secrets.json ``` -------------------------------- ### Missing Secrets Error Handling Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of how to handle missing required secrets. ```go secrets := map[string]string{"API_KEY": "..."} required := []string{"API_KEY", "DATABASE_URL"} missing := controllers.MissingSecrets(secrets, required) if len(missing) > 0 { log.Printf("Missing required secrets: %v", missing) } ``` -------------------------------- ### Handling Authentication Errors Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of how to handle a 401 Unauthorized error, prompting the user to log in. ```Go if err.Code == 401 { log.Fatal("Please run 'doppler login' to authenticate") } ``` -------------------------------- ### CreateDirectory Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Create directory with permissions. ```go func CreateDirectory(path string, permissions os.FileMode) error ``` -------------------------------- ### Process Execution Error Handling Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of handling errors when executing a process with `doppler run`. ```go cmd, err := controllers.Run(cobraCmd, args, env, true) if err != nil { log.Fatal("Execution failed:", err) } ``` -------------------------------- ### CreateProject Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Create a new project. ```go func CreateProject(host string, verifyTLS bool, apiKey string, name string, description string) (models.ProjectInfo, Error) ``` -------------------------------- ### Initialize Doppler CLI Source: https://github.com/dopplerhq/cli/blob/master/README.md Authenticate the CLI and link the current directory to a Doppler project and configuration. ```sh $ doppler login # generate auth credentials $ doppler setup # select your project and config # optional $ doppler configure --all # view local configuration ``` -------------------------------- ### Get Specific Config Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md JSON response for getting a specific config. ```json { "config": { "name": "prod", "root": true, "locked": true, "environment": "env_XXX", "project": "proj_XXX", "created_at": "2024-01-15T10:30:00Z", "last_fetch_at": "2024-01-20T14:22:00Z", "inheritable": true, "inherits": [], "inheritedBy": [ { "project": "proj_YYY", "config": "staging" } ] } } ``` -------------------------------- ### File I/O Error Handling Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of reading a template file, with the expectation that errors are checked by the caller. ```go content := controllers.ReadTemplateFile("/path/to/template") // Check for file errors in caller ``` -------------------------------- ### GET /v3/configs/config/secrets/names Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Response structure for getting a list of secret names. ```json { "names": ["API_KEY", "DATABASE_URL", "SECRET_TOKEN"] } ``` -------------------------------- ### Run Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Execute a command with injected environment variables. ```go func Run(cmd *cobra.Command, args []string, env []string, forwardSignals bool) (*exec.Cmd, error) ``` -------------------------------- ### PrepareSecrets Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Prepare environment variables and mount configuration for process execution. ```go func PrepareSecrets(dopplerSecrets map[string]string, secretsBytes []byte, originalEnv []string, preserveEnv string, mountOptions MountOptions) ([]string, func()) ``` -------------------------------- ### Cache/Fallback Error Handling Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of handling cache file operation errors and falling back to API fetch. ```go data, err := controllers.SecretsCacheFileBytes(path, passphrase) if !err.IsNil() { log.Printf("Cache error: %s", err.Message) // Fall back to API fetch } ``` -------------------------------- ### Handling Permission Errors Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of how to handle a 403 Forbidden error, indicating insufficient permissions for the operation. ```Go if err.Code == 403 { log.Fatal("Insufficient permissions for this operation") } ``` -------------------------------- ### Connection Errors with Timeout Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of using the `--timeout` flag to set a custom timeout duration for connection-related operations. ```Bash doppler --timeout 60s secrets download ``` -------------------------------- ### Handling HTTP Errors Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of how to handle HTTP errors returned by the Doppler CLI, checking if an error occurred and logging its message and code. ```Go import "github.com/DopplerHQ/cli/pkg/http" secrets, err := http.GetSecrets(...) if !err.IsNil() { // Handle error log.Printf("Error: %s (Code: %d)", err.Message, err.Code) } ``` -------------------------------- ### HTTP Timeouts Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Demonstrates how to customize HTTP request timeouts. ```bash doppler --timeout 60s secrets download # Disable timeout doppler --no-timeout secrets download ``` -------------------------------- ### Flag Parsing Error Examples Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Examples of CLI flag parsing errors, including invalid values and conflicting flags. ```bash # Invalid timeout value $ doppler --timeout abc secrets get API_KEY Error: invalid duration "abc" # Conflicting flags $ doppler --silent --debug secrets get API_KEY Warning: --silent has no effect when used with --debug ``` -------------------------------- ### CreateEnvironment Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Create a new environment in a project. ```go func CreateEnvironment(host string, verifyTLS bool, apiKey string, project string, name string, slug string) (models.EnvironmentInfo, Error) ``` -------------------------------- ### ConfigInfo Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/types.md Configuration metadata including inheritance hierarchy. ```go type ConfigInfo struct { Name string Root bool Locked bool Environment string Project string CreatedAt string InitialFetchAt string LastFetchAt string Inheritable bool Inherits []ConfigDescriptor InheritedBy []ConfigDescriptor } ``` -------------------------------- ### GetEnvironments Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md List environments in a project with pagination. ```go func GetEnvironments(host string, verifyTLS bool, apiKey string, project string, page int, number int) ([]models.EnvironmentInfo, Error) ``` -------------------------------- ### WriteFile Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Write contents to file. ```go func WriteFile(path string, content []byte, permissions os.FileMode) error ``` -------------------------------- ### CLIChangeLog Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Fetch CLI changelog. ```go func CLIChangeLog() (map[string]models.ChangeLog, http.Error) ``` -------------------------------- ### CreateConfig Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Create a new config. ```go func CreateConfig(host string, verifyTLS bool, apiKey string, project string, name string, environment string) (models.ConfigInfo, Error) ``` -------------------------------- ### Log Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Output generic log message. ```go func Log(message string) ``` -------------------------------- ### GetConfigs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md List configs in a project environment. ```go func GetConfigs(host string, verifyTLS bool, apiKey string, project string, environment string, page int, number int) ([]models.ConfigInfo, Error) ``` -------------------------------- ### GetProjects Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md List projects with pagination. ```go func GetProjects(host string, verifyTLS bool, apiKey string, page int, number int) ([]models.ProjectInfo, Error) ``` -------------------------------- ### GetConfigLogIDs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Get list of config log IDs. ```go func GetConfigLogIDs(config models.ScopedOptions) ([]string, Error) ``` -------------------------------- ### GetActivityLogIDs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Get list of activity log IDs. ```go func GetActivityLogIDs(config models.ScopedOptions) ([]string, Error) ``` -------------------------------- ### GetStringFlag Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Get string CLI flag value. ```go func GetStringFlag(cmd *cobra.Command, flag string) string ``` -------------------------------- ### GetPathFlagIfChanged Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Get path flag only if explicitly set. ```go func GetPathFlagIfChanged(cmd *cobra.Command, flag string, defaultValue string) string ``` -------------------------------- ### ProjectInfo Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/types.md Project metadata and information. ```go type ProjectInfo struct { ID string Name string Description string CreatedAt string } ``` -------------------------------- ### GetBoolFlag Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Get boolean CLI flag value. ```go func GetBoolFlag(cmd *cobra.Command, flag string) bool ``` -------------------------------- ### GetFile Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Read file contents. ```go func GetFile(path string) (string, error) ``` -------------------------------- ### TrimStartString Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Remove prefix from string. ```go func TrimStartString(s, prefix string) string ``` -------------------------------- ### GetEnvironmentIDs Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Get list of environment IDs for active project. ```go func GetEnvironmentIDs(config models.ScopedOptions) ([]string, Error) ``` -------------------------------- ### GetBoolFlagIfChanged Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Get boolean flag only if explicitly set by user. ```go func GetBoolFlagIfChanged(cmd *cobra.Command, flag string, defaultValue bool) bool ``` -------------------------------- ### GetEnv Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Get environment variable with optional default value. ```go func GetEnv(key string, defaultValue string) string ``` -------------------------------- ### LogInfo Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Output informational log message. ```go func LogInfo(message string) ``` -------------------------------- ### Enable Debug Output Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md How to enable debug logging for detailed operation information. ```bash doppler --debug secrets get API_KEY ``` -------------------------------- ### GET /v3/environments - Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Response for listing environments. ```json { "environments": [ { "id": "env_XXX", "name": "Production", "created_at": "2024-01-15T10:30:00Z", "initial_fetch_at": "2024-01-16T10:30:00Z", "project": "proj_XXX" } ] } ``` -------------------------------- ### GET /v3/projects - Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Response for listing projects. ```json { "projects": [ { "id": "proj_XXX", "name": "My Project", "description": "Project description", "created_at": "2024-01-15T10:30:00Z" } ] } ``` -------------------------------- ### Secret Mount Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Shows how to mount secrets as files for applications to access. ```bash doppler run --mount=/tmp/secrets.json -- myapp ``` -------------------------------- ### Disable TLS Certificate Verification Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Examples of how to disable TLS certificate verification. ```bash doppler --no-verify-tls secrets get API_KEY DOPPLER_VERIFY_TLS=false doppler secrets get API_KEY ``` -------------------------------- ### EnvironmentInfo Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/types.md Environment metadata and information. ```go type EnvironmentInfo struct { ID string Name string CreatedAt string InitialFetchAt string Project string } ``` -------------------------------- ### GET /v3/configs/config/secrets Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Response structure for fetching secrets for a config. ```json { "secrets": { "SECRET_NAME": { "raw": "raw_value", "computed": "computed_value", "rawVisibility": "restricted", "computedVisibility": "unmasked", "rawValueType": {"type": "string"}, "computedValueType": {"type": "string"}, "note": "Secret description" } } } ``` -------------------------------- ### 404 Not Found Error Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example JSON response for a 404 Not Found error. ```json { "error": "Resource not found" } ``` -------------------------------- ### FallbackOptions Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Options for fallback file handling. ```go type FallbackOptions struct { Enable bool Path string LegacyPath string Readonly bool Exclusive bool ExclusiveFlag string ExitOnWriteFailure bool Passphrase string } ``` -------------------------------- ### 401 Unauthorized Error Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example JSON response for a 401 Unauthorized error. ```json { "error": "Unauthorized - invalid token" } ``` -------------------------------- ### Template Rendering Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Illustrates rendering templates using secret values. ```bash doppler run --mount-template='{"db":"{{DATABASE_URL}}"}' -- app ``` -------------------------------- ### Generate and Export GPG Keys Source: https://github.com/dopplerhq/cli/blob/master/BUILD.md Commands to generate a GPG key, list keys, and export them for Doppler configuration. ```sh $ gpg --full-generate-key $ gpg --list-secret-keys # copy the key's 40-character ID $ gpg --armor --export-secret-key KEY_ID $ gpg --armor --export KEY_ID $ gpg --keyserver keyserver.ubuntu.com --send-key LAST_8_DIGITS_OF_KEY_ID ``` -------------------------------- ### Create service token response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example response structure for creating a service token. ```json { "token": { "name": "New Token", "token": "dp.cs_XXXXXXXXXXXXX", "slug": "new-token", "created_at": "2024-01-15T10:30:00Z", "expires_at": "2025-12-31T23:59:59Z", "project": "proj_XXX", "environment": "env_XXX", "config": "prod", "access": "read" } } ``` -------------------------------- ### View and Modify Configuration Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Demonstrates various ways to view and modify Doppler CLI configuration options. ```bash # View all config doppler configure --all # View specific option doppler configure --config token # Set option doppler configure --token doppler configure --project my-project doppler configure --api-host https://custom-api.doppler.com # Set flags doppler configure --flags analytics=false update-check=false ``` -------------------------------- ### List service tokens response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example response structure for listing service tokens. ```json { "tokens": [ { "name": "CI Token", "token": "dp.cs_...", "slug": "ci-token", "created_at": "2024-01-15T10:30:00Z", "expires_at": "2025-01-15T10:30:00Z", "project": "proj_XXX", "environment": "env_XXX", "config": "prod", "access": "read" } ] } ``` -------------------------------- ### List config logs response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example response structure for listing config logs. ```json { "logs": [ { "id": "log_XXX", "text": "Updated 3 secrets", "html": "...", "created_at": "2024-01-20T14:22:00Z", "config": "prod", "environment": "env_XXX", "project": "proj_XXX", "user": {...}, "diff": [ { "name": "API_KEY", "added": "new_value", "removed": "old_value" } ] } ] } ``` -------------------------------- ### MountOptions Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Options for mounting secrets as files. ```go type MountOptions struct { Enable bool Format string Path string Template string MaxReads int } ``` -------------------------------- ### List activity logs response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example response structure for listing activity logs. ```json { "activities": [ { "id": "act_XXX", "text": "User updated secret API_KEY", "html": "...", "created_at": "2024-01-20T14:22:00Z", "enclave_project": "proj_XXX", "enclave_environment": "env_XXX", "enclave_config": "prod", "user": { "email": "user@example.com", "name": "User Name", "username": "username", "profile_image_url": "..." } } ] } ``` -------------------------------- ### List service tokens for a config Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Lists all service tokens associated with a specific configuration. ```bash doppler configs tokens list --project my-project --config prod ``` -------------------------------- ### ScopedOptions Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/types.md Configuration options with their source information. ```Go type ScopedOptions struct { Token ScopedOption APIHost ScopedOption DashboardHost ScopedOption VerifyTLS ScopedOption EnclaveProject ScopedOption EnclaveConfig ScopedOption } ``` -------------------------------- ### Set config inheritance Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example request body to set a config's inheritance. ```json { "inherits": "prod,base" } ``` -------------------------------- ### HandleError Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Log an error and optionally exit. ```go func HandleError(err error, message ...string) ``` -------------------------------- ### 500 Internal Server Error Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example JSON response for a 500 Internal Server Error. ```json { "error": "Internal server error" } ``` -------------------------------- ### Execute command with secrets Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/INDEX.md Illustrates the process of preparing secrets and executing a command, with an option for file mounting. ```go controllers.PrepareSecrets() ``` ```go controllers.Run() ``` ```go controllers.MountSecrets() ``` -------------------------------- ### 429 Rate Limited Error Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example JSON response for a 429 Rate Limited error. ```json { "error": "Rate limit exceeded", "retry_after": 60 } ``` -------------------------------- ### Exists Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Check if file or directory exists. ```go func Exists(path string) bool ``` -------------------------------- ### 400 Bad Request Error Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example JSON response for a 400 Bad Request error. ```json { "error": "Invalid parameter: field_name" } ``` -------------------------------- ### Fallback (Offline) Support Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/configuration.md Enable Doppler to run applications with fallback support for offline use, with or without encryption. ```bash # Enable fallback with encryption doppler run --fallback --fallback-passpath ~/.doppler-passphrase -- myapp # Without encryption doppler run --fallback -- myapp ``` -------------------------------- ### Update Workplace Settings Response Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example JSON response after successfully updating workplace settings. ```json { "workplace": { "id": "wp_XXX", "name": "Updated Workplace", "billing_email": "newemail@example.com" } } ``` -------------------------------- ### Create service token request body Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/endpoints.md Example request body for creating a service token. ```json { "name": "New Token", "expires_at": "2025-12-31T23:59:59Z", "access": "read" } ``` -------------------------------- ### NewVersionAvailable Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Check if a new version is available and return version info. ```go func NewVersionAvailable(prevVersionCheck models.VersionCheck) (bool, models.VersionCheck, error) ``` -------------------------------- ### ToInt64 Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/utilities.md Convert string to int64. ```go func ToInt64(s string) (int64, error) ``` -------------------------------- ### Production (Silent) Environment Mode Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/cli-commands.md Example of using the `--silent` flag for production environments. ```bash doppler --silent run -- production-app ``` -------------------------------- ### MetadataFile Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/controllers.md Read cache metadata from file. ```go func MetadataFile(path string) (models.SecretsFileMetadata, Error) ``` -------------------------------- ### CloneConfig Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/api-reference/http-client.md Clone a config. ```go func CloneConfig(host string, verifyTLS bool, apiKey string, project string, config string, name string) (models.ConfigInfo, Error) ``` -------------------------------- ### Parse Error Handling Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of handling errors during API response or secret format parsing. ```go secrets, err := controllers.ParseSecrets(response) if err != nil { log.Fatal("Unable to parse secrets:", err) } ``` -------------------------------- ### Dangerous Secret Name Error Handling Source: https://github.com/dopplerhq/cli/blob/master/_autodocs/errors.md Example of how to handle the detection of dangerous secret names. ```go err := controllers.CheckForDangerousSecretNames(secrets) if err != nil { log.Printf("Warning: dangerous secret names detected: %v", err) } ```