Skip to content

Commit 24e6b2c

Browse files
committed
replicaed cli profile and .replicated docs
1 parent 2a17a17 commit 24e6b2c

File tree

9 files changed

+674
-4
lines changed

9 files changed

+674
-4
lines changed

docs/reference/cli-profiles.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# CLI Authentication Profiles
2+
3+
The Replicated CLI supports multiple authentication profiles, allowing you to manage and switch between different API credentials easily. This is useful when working with multiple Replicated accounts or environments.
4+
5+
## Overview
6+
7+
Authentication profiles store your API token and optionally custom API endpoints. Profiles are stored securely in `~/.replicated/config.yaml` with file permissions 600 (owner read/write only).
8+
9+
### Authentication Priority
10+
11+
The CLI determines which credentials to use in the following order:
12+
13+
1. `REPLICATED_API_TOKEN` environment variable (highest priority)
14+
2. `--profile` flag (per-command override)
15+
3. Default profile from `~/.replicated/config.yaml`
16+
4. Legacy single token (backward compatibility)
17+
18+
## Commands
19+
20+
### `replicated profile add [profile-name]`
21+
22+
Add a new authentication profile with the specified name.
23+
24+
**Flags:**
25+
- `--token` - API token for this profile (optional, will prompt if not provided). Supports environment variable expansion using `$VAR` or `${VAR}` syntax.
26+
27+
**Examples:**
28+
29+
```bash
30+
# Add a production profile (will prompt for token)
31+
replicated profile add prod
32+
33+
# Add a production profile with token flag
34+
replicated profile add prod --token=your-prod-token
35+
36+
# Add a profile using an existing environment variable
37+
replicated profile add prod --token='$REPLICATED_API_TOKEN'
38+
```
39+
40+
If a profile with the same name already exists, it will be updated. If you add the first profile or if no default profile is set, the newly added profile will automatically become the default.
41+
42+
**Note:** When using environment variables, make sure to quote the value (e.g., `'$REPLICATED_API_TOKEN'`) to prevent shell expansion and allow the CLI to expand it instead.
43+
44+
### `replicated profile ls`
45+
46+
List all authentication profiles.
47+
48+
**Examples:**
49+
50+
```bash
51+
replicated profile ls
52+
```
53+
54+
**Output:**
55+
56+
```
57+
DEFAULT NAME API ORIGIN REGISTRY ORIGIN
58+
* prod <default> <default>
59+
dev <default> <default>
60+
```
61+
62+
The asterisk (*) in the DEFAULT column indicates which profile is currently set as default.
63+
64+
### `replicated profile use [profile-name]`
65+
66+
Set the default authentication profile.
67+
68+
**Examples:**
69+
70+
```bash
71+
replicated profile use prod
72+
```
73+
74+
This command sets the specified profile as the default for all CLI operations. You can override the default on a per-command basis using the `--profile` flag.
75+
76+
### `replicated profile edit [profile-name]`
77+
78+
Edit an existing authentication profile. Only the flags you provide will be updated; other fields will remain unchanged.
79+
80+
**Flags:**
81+
- `--token` - New API token for this profile (optional). Supports environment variable expansion using `$VAR` or `${VAR}` syntax.
82+
83+
**Examples:**
84+
85+
```bash
86+
# Update the token for a profile
87+
replicated profile edit dev --token=new-dev-token
88+
89+
# Update a profile using an environment variable
90+
replicated profile edit dev --token='$REPLICATED_API_TOKEN'
91+
```
92+
93+
### `replicated profile rm [profile-name]`
94+
95+
Remove an authentication profile.
96+
97+
**Examples:**
98+
99+
```bash
100+
replicated profile rm dev
101+
```
102+
103+
If you remove the default profile and other profiles exist, one of the remaining profiles will be automatically set as the default.
104+
105+
### `replicated profile set-default [profile-name]`
106+
107+
Set the default authentication profile. This is an alias for `replicated profile use`.
108+
109+
**Examples:**
110+
111+
```bash
112+
replicated profile set-default prod
113+
```
114+
115+
## Usage Examples
116+
117+
### Basic Workflow
118+
119+
```bash
120+
# Add a production profile using an existing environment variable
121+
replicated profile add prod --token='$REPLICATED_API_TOKEN'
122+
123+
# Add a development profile with a direct token
124+
replicated profile add dev --token=your-dev-token
125+
126+
# List all profiles
127+
replicated profile ls
128+
129+
# Switch to production profile
130+
replicated profile use prod
131+
132+
# Use development profile for a single command
133+
replicated app ls --profile=dev
134+
135+
# Edit a profile's token
136+
replicated profile edit dev --token=new-dev-token
137+
138+
# Remove a profile
139+
replicated profile rm dev
140+
```
141+
142+
### Working with Multiple Accounts
143+
144+
```bash
145+
# Add profiles for different accounts
146+
replicated profile add company-a --token=token-a
147+
replicated profile add company-b --token=token-b
148+
149+
# Switch between accounts
150+
replicated profile use company-a
151+
replicated app ls # Lists apps for company-a
152+
153+
replicated profile use company-b
154+
replicated app ls # Lists apps for company-b
155+
```
156+
157+
## Security
158+
159+
- All credentials are stored in `~/.replicated/config.yaml` with file permissions 600 (owner read/write only)
160+
- Tokens are masked when prompted interactively
161+
- Environment variables take precedence, allowing temporary overrides without modifying stored profiles
162+
163+
## Troubleshooting
164+
165+
### Profile Not Found
166+
167+
If you see "profile not found", use `replicated profile ls` to list available profiles and verify the profile name.
168+
169+
### Permission Denied
170+
171+
If you encounter permission issues with `~/.replicated/config.yaml`, verify the file has the correct permissions:
172+
173+
```bash
174+
chmod 600 ~/.replicated/config.yaml
175+
```
176+
177+
### Multiple Profiles, Wrong One Being Used
178+
179+
Check the default profile with `replicated profile ls` and ensure the correct profile is marked with an asterisk (*). You can change the default with `replicated profile use [profile-name]`.

0 commit comments

Comments
 (0)